This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Implementation of a simple MLP network with one hidden layer. Tested on the iris data set. | |
# Requires: numpy, sklearn>=0.18.1, tensorflow>=1.0 | |
# NOTE: In order to make the code simple, we rewrite x * W_1 + b_1 = x' * W_1' | |
# where x' = [x | 1] and W_1' is the matrix W_1 appended with a new row with elements b_1's. | |
# Similarly, for h * W_2 + b_2 | |
import tensorflow as tf | |
import numpy as np | |
from sklearn import datasets | |
from sklearn.model_selection import train_test_split |