gpujs / gpu.js

GPU Accelerated JavaScript
https://gpu.rocks
MIT License
15.1k stars 654 forks source link

unhandled type "ObjectExpression" - what does this mean? #594

Closed theoparis closed 4 years ago

theoparis commented 4 years ago

What is wrong?

It gives this error and im not sure why: gpu-browser.min.js:14 Uncaught Error: unhandled type "ObjectExpression" at FunctionTracer.scan (gpu-browser.min.js:14)

Where does it happen?

Seems to be coming from this line

train(trainingData)

const trainingData = [[10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]]
const gpu = new GPU()
const network = new brain.recurrent.LSTMTimeStep()
const train = gpu.createKernel(function(data) {
  network.train(data, {
    iterations: 5000,
    log: (stats) => {
      console.log(stats)
    },
  })
}).setOutput([[100]]);

train(trainingData)

console.log(network.run([10, 9, 8, 7]))

How do we replicate the issue?

use my code with brain.js and gpu.js in the browser

How important is this (1-5)?

1-2

Expected behavior (i.e. solution)

Should have trained the netwrok.

Other Comments

theoparis commented 4 years ago

Also, it looks like brain.js added their own support for gpu.js with brain.NeuralNetworkGPU() but idk why this doesn't work still

harshkhandeparkar commented 4 years ago

You cannot use network.train. Network is a javascript object and gpu.js runs on a GPU. GPU is totally different than a CPU. You can only use arrays/numbers and manipulate those. Hence, brain.js has to provide its own support for GPU based training and there's a lot left to reach that goal.

theoparis commented 4 years ago

Oh, ok.

harshkhandeparkar commented 4 years ago

The GPU APIs were originally made only for parallel heavy computation and graphics. It isn't really made to fo normal work. The only reason why graphics cards are faster is because they do simple tasks in parallel not because they are superfast. If that was the case, we would have been able to use a GPU as a CPU.