tfjs
tfjs copied to clipboard
index.js:88 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length')
While trying to "Train" using this code I am getting an error:
DevTools failed to load source map: Could not load content for https://cdn.jsdelivr.net/npm/@tensorflow/tf.min.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE index.js:88 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length') at flatten (index.js:88:26) at train (index.js:48:23) at HTMLButtonElement.onclick (index.html:14:42)
This is on latest chrome browser on Windows 10 machine.
In order to expedite the trouble-shooting process, please provide a codepen example to reproduce the issue reported here. Thanks! Based on the error , I would say input parameter is not valid which you are passing.
Attached is my code (inde.html and index.js just remove the .pdf suffix and you can execute them). It is based on your sample. I think it used to work about a month ago when I had got it. Nothing changed from my side but now I am getting this error.
Open index.html, click on button "Train" and the UI will grey out completely. You can see the exception, error and stack trace that I reported in developer tools.
Could not open pdf , can you please paste here https://codepen.io/pen/ and share it.
Here you go: https://codepen.io/sameermahajan/pen/YzezQej
Initially I did not get which colab you were working on , by seeing the code I see you are TensorFlow.js - Audio recognition using transfer learning. I was able to run the colab successfully here https://codepen.io/rthadur/pen/JjpoKbE . Codepen which you shared is also working fine for me , could you please let me know where you are seeing the issue ?
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'type') at eval (barPolar.js?120a:63:1) at GlobalModel.eval (Global.js?05a0:682:1)
I am getting error as reported at line 88 of index.js when clicked on button "Train". I get the error locally as well as in uploaded codepen. It is with latest chrome on windows 10 machine in case it matters.
The initial part of the codelab that you have shared works for me. The issue is with "Train" part when I add and try it.
Sorry my windows machine is broken , could not test this , I have the complete example working here https://codepen.io/rthadur/pen/QWQvNpO , can you try this once. I had no issues running it. Thank you
I get the same error with this from my machine / browser. Developer tools show the same error and stack.
Also faced with this issue
<script type="text/javascript">
function start_model() {
// const modelJson = require('https://tempdeltavalue.github.io/model.json');
// const modelWeights = require('https://tempdeltavalue.github.io/group1-shard1of1.bin');
model = tf.loadGraphModel('https://tempdeltavalue.github.io/f_w2223_js_graph/model.json');
states =[];
next_char = ['Пр ']
result = [next_char]
const prediction = res.executeAsync(
{"args_0" : next_char, "unknown" : next_char, "unknown_8" : next_char},
// [next_char, states]
);
console.log(prediction);
}, function (err) {
console.log(err);
});
}
}
window.onload = start_model;
</script>
https://colab.research.google.com/drive/1zPeOgjKipPGyMJz-i99_LLFBYbr__JTr#scrollTo=DRKmCHi7vfSm
Hi @sameermahajan ,
I apologise for the delayed response. I have reviewed your code and encountered the same error you reported: index.js:88 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'length’) when attempting to train the model directly without any data. This error occurs due to passing an empty array to the flatten(tensors) function, resulting in a length error at the following line: const size = tensors[0].length.
To avoid this error, I suggest clicking on the left, right, or noise button first to fill the example array with some data using the following code: let vals = normalize(data.subarray(-frameSize * NUM_FRAMES)); examples.push({vals, label});. Once the example array has been populated with data, you can safely click on the train button without encountering any errors.
Output :
You could also refer to tf.tensor documentation. Let me know if have I missed something here. Thank You !
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you.
Closing as stale. Please @mention us if this needs more attention.