-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
Description
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js):
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 11
- TensorFlow.js installed from (npm or script link): NPM
- TensorFlow.js version (use command below): 4.18.0
Describe the current behavior
When creating a model stacking two LSTM ran into an error
Describe the expected behavior
- Input data can be dummy to reproduce the probleme.
- When removing the second LSTM everything is working.
Error during model training: Argument tensors passed to stack must be a
Tensor[]or
TensorLike[]
__________________________________________________________________________________________
Layer (type) Input Shape Output shape Param #
==========================================================================================
lstm_1 (LSTM) [[null,1,8]] [null,1,100] 43600
__________________________________________________________________________________________
dropout_1 (Dropout) [[null,1,100]] [null,1,100] 0
__________________________________________________________________________________________
bidirectional_lstm (Bidirec [[null,1,100]] [null,100] 160800
__________________________________________________________________________________________
dropout_2 (Dropout) [[null,100]] [null,100] 0
__________________________________________________________________________________________
dense_1 (Dense) [[null,100]] [null,1] 101
==========================================================================================
Total params: 204501
Trainable params: 204501
Non-trainable params: 0
__________________________________________________________________________________________
Standalone code to reproduce the issue
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.
const model = tf.sequential();
model.add(
tf.layers.lstm({
units: 100,
inputShape: [1, 8], // Flexible time steps, defined number of features
returnSequences: true,
kernelInitializer: "glorotUniform", // For the input kernel
recurrentInitializer: "orthogonal", // Especially good for RNNs
name: "lstm_1",
})
);
model.add(tf.layers.dropout({ rate: 0.3, name: "dropout_1" }));
model.add(
tf.layers.bidirectional({
layer: tf.layers.lstm({
units: 100,
returnSequences: false,
kernelInitializer: "glorotUniform",
recurrentInitializer: "orthogonal",
name: "lstm_2",
}),
name: "bidirectional_lstm",
mergeMode: "ave",
})
);
model.add(tf.layers.dropout({ rate: 0.3, name: "dropout_2" }));
model.add(
tf.layers.dense({
units: 1,
activation: "sigmoid",
kernelInitializer: "glorotUniform",
name: "dense_1",
})
);
model.compile({
optimizer: "adam",
loss: "binaryCrossentropy",
metrics: ["accuracy"],
});
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.
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
gaikwadrahul8 commentedon Apr 22, 2024
Hi, @kzay
Thank you for reporting this issue. I attempted to reproduce it using the following code snippet on my
Mac M1 system
and did not encounter theArgument tensors passed to stack must be a Tensor[] or TensorLike[]
error. Since you're using aWindows 11
system, it's possible the issue might be specific to that platform. Could you confirm if there are any relevant differences in your environment or perhaps guide me on further steps to replicate the same behavior on my end?Output of above code snippet :
Thank you for your cooperation and patience.
kzay commentedon Apr 23, 2024
Thank @gaikwadrahul8 , the only major change done is fixing the lib folder of the NPM package as mentionned in an other ticket to fix an issue about the binding by copying the *.dll from napi v9 to v8
Error without the DLL :
Error: The specified module could not be found. ***\node_modules\@tensorflow\tfjs-node\lib\napi-v8\tfjs_binding.node
I also downgraded to Node 19 and dont need to make this fix anymore
kzay commentedon Apr 27, 2024
Started from fresh and simple install.
Scenario 1 : Windows 11, NodeJS 19.9.0, Python 3.9.13
Scenario 2 : Docker Image (tensorflow/tensorflow:latest), NodeJS latest
Same results on both scenario: with only one lstm it's working well, but get the error when adding a second layers of lstm
kzay commentedon May 5, 2024
Also happening with GRU