In [1]:
from opendeep.models.container import Prototype
from opendeep.models.single_layer.basic import BasicLayer, SoftmaxLayer
from opendeep.optimization.adadelta import AdaDelta
from opendeep.data.standard_datasets.image.mnist import MNIST
from opendeep.data.dataset import TEST

In [2]:
# define the model layers
relu_layer1 = BasicLayer(input_size=784, output_size=1000, activation='rectifier')
relu_layer2 = BasicLayer(inputs_hook=(1000, relu_layer1.get_outputs()), output_size=1000, activation='rectifier')
class_layer3 = SoftmaxLayer(inputs_hook=(1000, relu_layer2.get_outputs()), output_size=10, out_as_probs=False)
# add the layers as a Prototype
mlp = Prototype(layers=[relu_layer1, relu_layer2, class_layer3])

mnist = MNIST()

optimizer = AdaDelta(model=mlp, dataset=mnist, n_epoch=2)
optimizer.train()

test_data, test_labels = mnist.getSubset(TEST)
test_data = test_data[:25].eval()
test_labels = test_labels[:25].eval()

# use the run function!
preds = mlp.run(test_data)


WARNING:opendeep.models.model:No input_size or inputs_hook! Make sure this is done in a Container. Setting input_size=1 for the Container now...
WARNING:opendeep.models.model:No output_size given! Make sure this is from a generative model (where output_size is thesame as input_size. Setting output_size=input_size now...

In [3]:
preds


Out[3]:
array([7, 2, 1, 0, 4, 1, 4, 9, 6, 9, 0, 6, 9, 0, 1, 5, 9, 7, 3, 4, 9, 6, 6,
       5, 4])

In [ ]: