Is bidirectional for LSTM even supported ? I am getting empty ( in C#/Tensorflow.NET 0 parameters) [Question]:
Description
ILayer forwardLayer = keras.layers.LSTM(units: 10, activation: keras.activations.Sigmoid, return_sequences: true, go_backwards: false);
ILayer backwardlayer = keras.layers.LSTM(units: 10, activation: keras.activations.Sigmoid, return_sequences: true, go_backwards: true);
model.add(keras.layers.Bidirectional(forwardLayer, merge_mode: "sum", backward_layer: backwardlayer));
Alternatives
No response
Have you checked this example? https://github.com/SciSharp/SciSharp.Models/blob/8bd848c3bc67395d4c787e15e8eddf7ed6707fdf/SciSharp.Models.TimeSeries/RNNModel.cs#L14
Yes, it has been support. You can refer to https://github.com/SciSharp/TensorFlow.NET/blob/8cab730f98112a845461bb635f137e220f272adb/test/TensorFlowNET.Keras.UnitTest/Layers/Rnn.Test.cs#L158-L165
But it may not have tested all parameters and situations like you set go_backwards to true in backward_layer here. So it may have some bugs here. And could you mind to provide more information, such as a minimal code for reproduction and more error information?
after the model is defined, it model.summary() retuns zero parameters for the bidirectional layers this gives zro parameters i summary public static void buildModel2() { //int embed_dim = 256; int lstm_out = 196; // var max_features = 4000; var model = keras.Sequential(); //model.add(keras.layers.Embedding(max_features, embed_dim, input_length : 35)); model.add(keras.layers.Dropout(0.4f)); // SpatialDropout1D model.add(keras.layers.Bidirectional(keras.layers.LSTM(lstm_out, dropout: 0.05f, recurrent_dropout: 0.2f))); // Add f model.add(keras.layers.Dense(2, activation : keras.activations.Softmax)); // replace 'Softmax' with keras.activations.Softmax model.compile(loss: "MeanSquaredError", optimizer: "adam", metrics: new string[] { "accuracy" }); model.summary(); }
This gives no parameters in model.summary()
public static void buildModel2() { //int embed_dim = 256; int lstm_out = 196; // var max_features = 4000; var model = keras.Sequential(); //model.add(keras.layers.Embedding(max_features, embed_dim, input_length : 35)); model.add(keras.layers.Dropout(0.4f)); // SpatialDropout1D model.add(keras.layers.Bidirectional(keras.layers.LSTM(lstm_out, dropout: 0.05f, recurrent_dropout: 0.2f))); // Add f model.add(keras.layers.Dense(2, activation : keras.activations.Softmax)); // replace 'Softmax' with keras.activations.Softmax model.compile(loss: "MeanSquaredError", optimizer: "adam", metrics: new string[] { "accuracy" }); model.summary(); }
I encountered a similar problem, did you manage to find a solution?
Tensor.NET is full of bug and inconsistencies… Better not to use it
From: Maciej Sobkowiak @.> Sent: Wednesday, August 14, 2024 6:37 AM To: SciSharp/TensorFlow.NET @.> Cc: Hook, Jaroslav @.>; Author @.> Subject: Re: [SciSharp/TensorFlow.NET] Is bidirectional for LSTM even supported ? I am getting empty ( in C#/Tensorflow.NET 0 parameters) [Question]: (Issue #1227)
CAUTION: This email originated from outside of Thermo Fisher Scientific. If you believe it to be suspicious, report using the Report Phish button in Outlook or send to @.***
I encountered a similar problem, did you manage to find a solution?
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/SciSharp/TensorFlow.NET/issues/1227*issuecomment-2288511363__;Iw!!HLrAl2XzZ3iCLg!DQEi2LZY0_Az3AH8pm0bLesqbAQ44bSDgmjjLzfJeSb9XRmtemaFYCYWFss97ktG89A3ol0NKeJIrLDxDc8dnIyd7M7RcbCZ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AWWYDG2HQRCKY5ZRWKKIZ5DZRM6MLAVCNFSM6AAAAABB5PTAN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBYGUYTCMZWGM__;!!HLrAl2XzZ3iCLg!DQEi2LZY0_Az3AH8pm0bLesqbAQ44bSDgmjjLzfJeSb9XRmtemaFYCYWFss97ktG89A3ol0NKeJIrLDxDc8dnIyd7PnUgGQD$. You are receiving this because you authored the thread.Message ID: @.@.>>
If you dont mind me asking, do you find any better alternative, or you stick with Python version?
Maybe have you tried using python inside .NET with Python.NET?
I tried to implement LSTM ( both training and inference) in Tensor.NET. LSTM Training was OK with some difficulties ( even though some features were missing), but when I switched the inference was a total disaster: VS started complaining on some version inconsistencies, some missing libraries, non-existing functions etc… Basically Tensorflow.NET is an inconsistent mess: the things do not work as advertised... I would not waste time on it … Stick with Python.
From: Maciej Sobkowiak @.> Sent: Wednesday, August 14, 2024 11:17 AM To: SciSharp/TensorFlow.NET @.> Cc: Hook, Jaroslav @.>; Author @.> Subject: Re: [SciSharp/TensorFlow.NET] Is bidirectional for LSTM even supported ? I am getting empty ( in C#/Tensorflow.NET 0 parameters) [Question]: (Issue #1227)
CAUTION: This email originated from outside of Thermo Fisher Scientific. If you believe it to be suspicious, report using the Report Phish button in Outlook or send to @.***
If you dont mind me asking, do you find any better alternative, or you stick with Python version?
Maybe have you tried using python inside .NET with Python.NET?
— Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/SciSharp/TensorFlow.NET/issues/1227*issuecomment-2289225668__;Iw!!HLrAl2XzZ3iCLg!BiIK8vAY6dMMLCrEq6CW1r989bul0C-bXhVsH6cilT0NkeN8XKbJzy3xPm7uyC85zWkhU6LbCugtdPUF5BLzot1nVbJsuOMJ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AWWYDGZJZJ7IFKBJHRC5RLLZRN7G5AVCNFSM6AAAAABB5PTAN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOBZGIZDKNRWHA__;!!HLrAl2XzZ3iCLg!BiIK8vAY6dMMLCrEq6CW1r989bul0C-bXhVsH6cilT0NkeN8XKbJzy3xPm7uyC85zWkhU6LbCugtdPUF5BLzot1nVVGlYaTe$. You are receiving this because you authored the thread.Message ID: @.@.>>