zomux / deepy

A highly extensible deep learning framework
MIT License
422 stars 68 forks source link

NameError: Dropout not defined #2

Closed urwithajit9 closed 9 years ago

urwithajit9 commented 9 years ago

Hi, I am trying to execute the sample code given as example and by running the below line

model.stack(Dense(256, 'relu'), Dropout(0.2), Dense(256, 'relu'), Dropout(0.2), Dense(10, 'linear'), Softmax())

I am getting error: Traceback (most recent call last): File "", line 1, in NameError: name 'Dropout' is not defined Do i am making any mistake? or there is any problem with the library?

zomux commented 9 years ago

Sorry I forgot to import Dropout layer. The document was fixed now.

You should run this:

import logging, os
logging.basicConfig(level=logging.INFO)

from deepy.dataset import MnistDataset, MiniBatches
from deepy.networks import NeuralClassifier
from deepy.layers import Dense, Softmax, Dropout
from deepy.trainers import MomentumTrainer, LearningRateAnnealer

if __name__ == '__main__':
    model = NeuralClassifier(input_dim=28*28)
    model.stack(Dense(256, 'relu'),
                Dropout(0.2),
                Dense(256, 'relu'),
                Dropout(0.2),
                Dense(10, 'linear'),
                Softmax())

    trainer = MomentumTrainer(model)

    annealer = LearningRateAnnealer(trainer)

    mnist = MiniBatches(MnistDataset(), batch_size=20)

    trainer.run(mnist, controllers=[annealer])
zomux commented 9 years ago

Or simply

python experiments/mnist/mlp_dropout.py

See https://github.com/uaca/deepy for a full list of experiments

RAravindDS commented 2 years ago

Is there any command to download Dropout?