To get help from the community, check out our Google group.
0.12.4
The example here is not working properly:
https://github.com/tensorflow/tfjs-examples/tree/master/mnist-node
When I add yarn followed by node index.js, I get the following error:
(node:199628) UnhandledPromiseRejectionWarning: TypeError: backend.select is not a function
at environment_1.ENV.engine.runKernel.$condition (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/ops/logical_ops.js:88:83)
at /usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:115:26
at Engine.scopedRun (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:95:23)
at Engine.runKernel (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:113:14)
at where_ (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/ops/logical_ops.js:88:37)
at Object.where (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/ops/operation.js:23:29)
at Tensor.where (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/tensor.js:554:26)
at Object.$x (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/ops/unary_ops.js:113:41)
at Object.backpropagateGradients (/usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/tape.js:81:47)
at /usr/local/google/home/cais/tfjs/tfjs-examples/mnist-node/node_modules/@tensorflow/tfjs-core/dist/engine.js:288:20
FYI @nkreeger
I get the same:
yarn add @tensorflow/tfjs @tensorflow/tfjs-core @tensorflow/tfjs-node
With the following function:
// tslint:disable: no-import-side-effect
import * as tf from '@tensorflow/tfjs'
import '@tensorflow/tfjs-node'
export const predictBinaryCrossEntropy = async (
xs: number[][], // tslint:disable-line
ys: number[] // tslint:disable-line
): Promise<void> => {
const txs = tf.tensor(xs)
const tys = tf.tensor(ys)
const xUnits = xs.length * xs[0].length
const model = tf.sequential()
model.add(
tf.layers.dense({
units: xUnits,
inputShape: [2],
activation: 'tanh'
})
)
model.add(tf.layers.dense({ units: 1, activation: 'sigmoid' }))
model.compile({ optimizer: 'sgd', loss: 'binaryCrossentropy' })
await model.fit(txs, tys, {
batchSize: 1,
epochs: 5000
})
const results = model.predict(txs)
console.log(results)
}
Results in:
TypeError: backend.select is not a function
When run like so:
import { predictBinaryCrossEntropy } from '../src'
describe('predict', () => {
it('should predict with real xs and binary ys', async () => {
const xs = [[0, 0], [0, 1], [1, 0], [1, 1]]
const ys = [0, 1, 1, 0]
await predictBinaryCrossEntropy(xs, ys)
})
})
FWIW, also getting a 2018-07-30 17:46:05.489358: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.2 AVX AVX2 FMA
Also cc @kangyizhang
This should because of some ops updates in tfjs-core KernelBackend. I'm updating NodeJSKernelBakcend to fix it.
Just to diagnose this a little more, this is because of the loose versioning here:
https://github.com/tensorflow/tfjs-node/blob/master/package.json#L42
Every time we add a kernel backend and update, you'll break. I wonder if this should be an exact version. cc @dsmilkov
What is the temporary fix for this? Use specific tfjs and tfjs-node versions?
It's fixed by tfjs-node 0.1.10