Skip to content

Instantly share code, notes, and snippets.

@wbaek
Created September 7, 2015 14:57
Show Gist options
  • Save wbaek/4cd89072ddb375ac2160 to your computer and use it in GitHub Desktop.
Save wbaek/4cd89072ddb375ac2160 to your computer and use it in GitHub Desktop.
ipython_test.py
import theano
import sklearn.datasets
# Generate synthetic data
N_CLASSES = 3
X, y = sklearn.datasets.make_classification(n_features=2, n_redundant=0,
n_classes=N_CLASSES, n_clusters_per_class=1)
# Convert to theano floatX
X = X.astype(theano.config.floatX)
# Labels should be ints
y = y.astype('int32')
from lasagne.layers import *
from lasagne.nonlinearities import *
layers = [
(InputLayer, {'shape': X.shape}),
(DenseLayer, {'num_units': N_CLASSES, 'nonlinearity': softmax} ),
]
from nolearn.lasagne import NeuralNet
from lasagne.objectives import *
from lasagne.updates import *
net = NeuralNet(
layers=layers,
max_epochs = 10,
update=sgd,
update_learning_rate=1,
verbose=0,
)
_ = net.fit(X, y)
import matplotlib.pyplot as plt
%matplotlib inline
from nolearn.lasagne.visualize import plot_loss
plot_loss(net)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment