Description
Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): I wrote custom code
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):Windows 11 专业版
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow.js installed from (npm or script link): npm
- TensorFlow.js version (use command below): @tensorflow/[email protected], @tensorflow/[email protected]
- Browser version:
- Tensorflow.js Converter Version:@tensorflow/[email protected]
Describe the current behavior
tf.layers.conv2d are used in the model,Set the tf.setBackend('wasm'),Errors are reported during training:Error: Kernel 'Conv2DBackpropFilter' not registered for backend 'wasm'
Describe the expected behavior
No errors
Standalone code to reproduce the issue
import * as tf from '@tensorflow/tfjs-node';
import '@tensorflow/tfjs-backend-wasm';
createModel(){
const model = tf.sequential();
model.add(
tf.layers.conv2d({
inputShape: [130,6,1],
kernelSize: 3,
filters: 6,
strides: 1,
activation: 'relu',
kernelInitializer: 'varianceScaling',
}),
);
model.add(tf.layers.maxPooling2d({ poolSize: [2, 2], strides: [2, 2] }));
model.add(
tf.layers.conv2d({
kernelSize: 1,
filters: 2,
strides: 1,
activation: 'relu',
kernelInitializer: 'varianceScaling',
}),
);
model.add(tf.layers.maxPooling2d({ poolSize: [2, 2], strides: [2, 2] }));
model.add(tf.layers.flatten());
model.add(
tf.layers.dense({
units: 60,
kernelRegularizer: tf.regularizers.l2({ l2: 0.001 }),
kernelInitializer: 'varianceScaling',
activation: 'relu',
}),
);
model.add(
tf.layers.dense({
units:21,
kernelInitializer: 'varianceScaling',
activation: 'softmax',
}),
);
const optimizer = tf.train.adam();
model.compile({
optimizer: optimizer,
loss: 'categoricalCrossentropy',
metrics: ['accuracy'],
});
return model;
}
async modelFit(model,asyncData
): {
this.setFitState(true);
const data = tf.data
.generator(asyncData)
.shuffle(512)
.batch(512);
await model
.fitDataset(data, {
epochs: 10,
callbacks: {
onTrainBegin: async (logs) => {
this.batchTmie = Date.now();
},
onBatchEnd: (batch, logs)=>{
console.log(batch = ${batch},times=${Date.now()
)
},
onEpochEnd: async (epoch, logs)=>{
console.log(Epoch ${epoch}:loss = ${logs.loss}
);
},
},
})
.then(async () => {
await this.saveModel();
})
.catch((e) => {
console.error(e
});
}
const model=createModel()
modelFit(model, data);
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/CodePen/any notebook.
Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.