Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeStep classes not exported? #199

Closed
torreyleonard opened this issue Apr 23, 2018 · 4 comments
Closed

TimeStep classes not exported? #199

torreyleonard opened this issue Apr 23, 2018 · 4 comments
Assignees
Labels

Comments

@torreyleonard
Copy link

"If you don't mind add a fun gif or meme, but no pressure"

A GIF or MEME to give some spice of the internet

I know this feature was released just a few days ago so I thought I'd open this issue to help with its progress, although this could just be me overlooking something.

Instantiating a new LSTMTimeStep returns the error below, and brain.recurrent.LSTMTimeStep is undefined. I fixed this by exporting it in the compiled index.js, then instantiating with .default():

// Before

const net = new brain.recurrent.LSTMTimeStep.(options);

// const net = new brain.recurrent.LSTMTimeStep({
//             ^
// TypeError: brain.recurrent.LSTMTimeStep is not a constructor


// After

const net = new brain.recurrent.LSTMTimeStep.default(options);

// dist/index.js
var LSTMTimeStep = require('./dist/recurrent/lstm-time-step');
var brain = {
  crossValidate: crossValidate,
  likely: likely,
  lookup: lookup,
  NeuralNetwork: NeuralNetwork,
  NeuralNetworkGPU: NeuralNetworkGPU,
  TrainStream: TrainStream,
  recurrent: {
    RNN: RNN,
    LSTM: LSTM,
    GRU: GRU,
    LSTMTimeStep: LSTMTimeStep // <---
  },
  utilities: utilities
};

I'm sure that this problem would apply to the other "TimeStep" classes as well, but I've only tested it on RNNTimeStep which does indeed produce the same error.

@robertleeplummerjr
Copy link
Contributor

How are you importing brain?

@torreyleonard
Copy link
Author

Using const brain = require('brain.js');

@thingbuilder
Copy link

I get the same error, my code is:

const brain = require('brain.js');
const net = new brain.recurrent.LSTMTimeStep();
net.train([1,2,3]);
var output = net.run([1, 2]);  // 3
console.log(output);

error:

const net = new brain.recurrent.LSTMTimeStep();
            ^

TypeError: brain.recurrent.LSTMTimeStep is not a constructor

if I use const brain = require('brain.js').recurrent;
I get this error:

const net = new brain.recurrent.LSTMTimeStep();
                               ^

TypeError: Cannot read property 'LSTMTimeStep' of undefined

@robertleeplummerjr
Copy link
Contributor

Released v1.2.1 to address this. Ty for finding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants