Description
Description
python代码:
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
inputs = tf.random.normal([32, 10, 8])
lstm = tf.keras.layers.LSTM(4)
output = lstm(inputs)
print(output.shape)
#(32, 4)
lstm = tf.keras.layers.LSTM(4, return_sequences=True, return_state=True)
whole_seq_output, final_memory_state, final_carry_state = lstm(inputs)
print(whole_seq_output.shape)
#(32, 10, 4)
print(final_memory_state.shape)
#(32, 4)
print(final_carry_state.shape)
#(32, 4)
C#代码:
var inputs = tf.random.normal(new Shape(32, 10, 8));
var lstm = new Tensorflow.Keras.Layers.LSTM(new LSTMArgs()
{
Units = 4,
//InputShape = new Shape(10,8)
});
var y = lstm.Apply(inputs);//在这个位置报错,提示索引超出范围
print(y.shape);
Reproduction Steps
No response
Known Workarounds
无解决办法
No response
Configuration and Other Information
No response