Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: deepqlearn is not defined

See original GitHub issue

Followed your example and suddenly it cannot find deepqlearn. I’m doing this in Node.js.

var convnetjs = require('convnetjs');
// the normal examples with layer_defs etc. worked, but not this:
var brain = new deepqlearn.Brain(3, 2); // 3 inputs, 2 possible outputs (0,1)
var state = [Math.random(), Math.random(), Math.random()];
for(var k=0;k<10000;k++) {
    var action = brain.forward(state); // returns index of chosen action
    var reward = action === 0 ? 1.0 : 0.0;
    brain.backward(reward); // <-- learning magic happens here
    state[Math.floor(Math.random()*3)] += Math.random()*2-0.5;
brain.epsilon_test_time = 0.0; // don't make any more random choices
brain.learning = false;
// get an optimal action from the learned policy
var action = brain.forward(array_with_num_inputs_numbers);

Seems like it can’t find deepqlearn. Saw under node_modules/convnet/deepqlearn.js there’s an export statement; but your package.json specifies convnet.js as the main.

Issue Analytics

  • State:open
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

kengzcommented, Aug 28, 2015

Yeah node.js has a slightly different way of importing dependencies.

A quick and dirty solution is to simply go into node_modules/convnetjs/build/deepqlearn.js manually and add these two lines at the top:

// deepqlearn.js
var convnetjs = require(__dirname+'/convnet.js');
var cnnutil = require(__dirname+'/util.js');
kengzcommented, Nov 2, 2015

@SimplyY If by that you mean if it can run like an efficient program on Java/C++, then yes. Nodejs is a complete and performant language like Python. I just wanted to get rid of the browser dependency here and use convnet like a programming library.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught ReferenceError: WE is not defined in WebGL Earth
I'm implementing WebGL Earth on my local system i'm getting this error. Uncaught ReferenceError: WE is not defined.
Read more >
How to fix "Uncaught ReferenceError: x is not defined" in ...
JS Casts 04 - How to fix "Uncaught TypeError: x is not a function " in JavaScript.Visit for a summary ...
Read more >
Uncaught ReferenceError $ is not defined - YouTube
The video shows how to correct the " Uncaught ReferenceError : $ is not defined "#WEB_DEVELOPMENT.
Read more >
ConvNetJS Deep Q Learning Demo
The paper is a nice demo of a fairly standard (model-free) Reinforcement Learning algorithm (Q Learning) learning to play Atari games. In this...
Read more >
How to fix ReferenceError: _gaq is not defined
Looking for a way to fix the _gaq is not defined JavaScript error? Simply add this code snippet before the close of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found