TypeError: Cannot read property 'length' of null (dilations is null in depthwiseConv2dNativeBackpropInput_)
See original GitHub issueSystem information
- From the simple-object-detection example
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): tried both on Mac OS and Windows and Windows WSL
- TensorFlow.js installed from (npm or script link): npm library
- TensorFlow.js version (use command below): tested on ^2.6.0 and ^3.3.0
Describe the current behavior
Playing with the simple-object-detection example. Ran npm run train
and the following happens
Step 1: (Phase 1 of 2: initial transfer learning) - this runs without any problems
const tBegin = tf.util.now();
console.log(`Generating ${args.numExamples} training data...`);
const { images, targets } = await trainingData();
const { model, fineTuningLayers } = await buildObjectDetectionModel();
model.compile({ loss: customLossFunction, optimizer: tf.train.rmsprop(5e-3) });
model.summary();
// Initial phase of transfer learning.
// console.log('Images Shape:', images.shape);
// console.log('Targets Shape', targets.shape);
console.log('Phase 1 of 2: initial transfer learning');
await model.fit(images, targets, {
epochs: args.initialTransferEpochs,
batchSize: args.batchSize,
validationSplit: args.validationSplit,
callbacks: args.logDir == null ? null : tfn.node.tensorBoard(args.logDir, {
updateFreq: args.logUpdateFreq
})
});
Step 2: (Phase 2 of 2: fine-tuning phase) - this is where it breaks
// Fine-tuning phase of transfer learning.
// Unfreeze layers for fine-tuning.
for (const layer of fineTuningLayers) {
console.log(fineTuningLayers);
layer.trainable = true;
}
model.compile({ loss: customLossFunction, optimizer: tf.train.rmsprop(2e-3) });
model.summary();
// Do fine-tuning.
// The batch size is reduced to avoid CPU/GPU OOM. This has
// to do with the unfreezing of the fine-tuning layers above,
// which leads to higher memory consumption during backpropagation.
console.log('Phase 2 of 2: fine-tuning phase. Top Layer Name:', topLayerName, 'Group Names:', topLayerGroupNames);
await model.fit(images, targets, {
epochs: args.fineTuningEpochs,
batchSize: Math.round(args.batchSize / 2),
validationSplit: args.validationSplit,
callbacks: args.logDir == null ? null : tfn.node.tensorBoard(args.logDir, {
updateFreq: args.logUpdateFreq
})
});
I get this error after model.fit(images, targets, {...
is executed:
I debugged down a bit further - turns out that somewhere at the kernel input (I think??), it’s giving a dilation value of null
(should be number
or number[]
).
Please advise, I’m going off the tfjs-examples repo simple-object-dectection https://github.com/tensorflow/tfjs-examples/blob/master/simple-object-detection/package.json
…then just running npm install
and npm run train
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
[Solved] TypeError: Cannot read property 'length' of null
The TypeError: Cannot read property 'length' of null occurs if you are trying to get the length of an object that is null....
Read more >Uncaught TypeError: Cannot read property 'length' of null- ...
If when fetching localStorage.getItem('options') and there is no stored "options" key-value, then null is returned. You then JSON parse this, ...
Read more >Resolve Netsuite Scripting Error “Cannot read property “length ...
This error occurs when you try to get length of search record object which returns a null value. Length method can be used...
Read more >Typeerror: Cannot Read Property 'length' of Undefined
The length property returns a number for essentially any object in JavaScript. Typeerrors can be thrown when attempting to change a value that ......
Read more >Fix 'cannot read properties of null (reading length)' in JS
Learn what is the cause, and how you can fix 'Uncaught TypeError: Cannot read properties of null (reading 'length')' errors in JavaScript.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Still broken, but found a workaround (though probably the model is not even transfer learning)
@tensorflow/tfjs
to@tensorflow/tfjs-node
const topLayerGroupNames = ['conv_pw_9', 'conv_pw_10', 'conv_pw_11'];
toconst topLayerGroupNames = [ 'conv_pw_11'];
Both changes are required, one without the other leads to the same problem. I have no idea why this fixes it.
Are you satisfied with the resolution of your issue? Yes No