Git Product home page Git Product logo

Comments (3)

bmilde avatar bmilde commented on July 20, 2024

I have put together this simple example fitting nolearns NeuralNet on MNIST, which also doesn't run on my machine (nan for losses + valid acc does not improve). Could you try to run it?

from lasagne import layers
from lasagne import init

from lasagne.updates import sgd,nesterov_momentum
from nolearn.lasagne import NeuralNet

import numpy as np

from sklearn.datasets import fetch_mldata
from sklearn.utils import shuffle

DATA_PATH = '~/data'

mnist = fetch_mldata('MNIST original', data_home=DATA_PATH)

train = mnist.data[:60000].astype(np.float32)
train_labels = mnist.target[:60000].astype(np.int32)

train, train_labels = shuffle(train, train_labels, random_state=42)

print 'train.shape:',train.shape,'train.dtype:',train.dtype,'train_labels.dtype:',train_labels.dtype

clf = NeuralNet(
    layers=[
        ('input', layers.InputLayer),
        ('hidden', layers.DenseLayer),
        ('output', layers.DenseLayer),
        ],
    input_shape = (None, train.shape[1]),
    hidden_num_units=100,
    output_num_units=10,
    output_nonlinearity=None,

    update=nesterov_momentum,
    #update=sgd,
    update_learning_rate=0.01,
    update_momentum=0.9,

    regression=False,
    max_epochs=1000,
    verbose=1,

    #W=init.Uniform()

    )

clf.fit(train,train_labels)

from nolearn.

dnouri avatar dnouri commented on July 20, 2024

I think what you're missing is output_nonlinearity=lasagne.nonlinearities.softmax. Sorry for a lack of proper documentation for this. But there's an MNIST example included in the tests if you want to have a look: https://github.com/dnouri/nolearn/blob/master/nolearn/tests/test_lasagne.py#L41-L91

from nolearn.

bmilde avatar bmilde commented on July 20, 2024

Ah, thanks, yes that was it! Apparently I looked into every other parameter besides output_nonlinearity... thanks again!

from nolearn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.