来自Tensorflow代码:丹索尔·弗洛.RnnCell。
num_units: int, The number of units in the LSTM cell.
我不明白这意味着什么。LSTM单元的单位是什么?输入,输出和忘记门?这是否意味着“深层LSTM的递归投影层中的单元数”?那为什么它被称为“LSTM单元中的单元数”?什么是LSTM单元,它与LSTM块有什么不同?如果不是单元,最小LSTM单元是什么?
在我的模型上运行训练时,我有这个错误。我在不同的网站上发现了这个问题,但找不到解决问题的办法。
这是我的模型:
import keras
import tensorflow as tf
import tensorflow.keras.layers as L
import tensorflow.keras.models as M
import tensorflow.keras.callbacks as C
import tensorflow.keras.utils as U
def make_model_lstm_pooling(inshape=50000):
z = L.Input(
在这里,您可能会看到TensorFlow中几个堆叠的LSTM单元的标准实现。
with tf.name_scope("RNN_layers"):
def lstm_cell():
lstm = tf.contrib.rnn.LayerNormBasicLSTMCell(lstm_size)
return lstm
cell = tf.contrib.rnn.MultiRNNCell([lstm_cell() for _ in range(num_layers)])
with tf.name_scope("RNN_init
与此相关:
我正在尝试复制lstm解码单元的值,以便在其他地方使用它进行波束搜索。在伪代码中,我希望是这样的:
lstm_decode = tf.nn.rnn_cell(...)
training_output = tf.nn.seq2seq.rnn_decoder(...)
... do training by back-prop the error on trainint_output ...
# duplicate the lstm_decode unit (same weights)
lstm_decode_copy = copy(lstm_decode)
... do beam s
我尝试构建一个长度可变的LSTM。首先,我创建LSTM单元,然后堆叠一个具有2个输出节点的完全连接层。代码如下: from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import LSTM, Dense, TimeDistributed
from tensorflow.keras.utils import to_categorical
import numpy as np
model = Sequential()
model.add(LSTM(32, return_sequences=Tr
我看到了在tensorflow上调用lstm的两种不同的方法,我对一种方法和另一种方法的区别感到困惑。在哪种情况下使用其中一种
第一种方法是创建一个lstm,然后像下面的代码那样立即调用它
lstm = rnn_cell.BasicLSTMCell(lstm_size)
# Initial state of the LSTM memory.
initial_state = tf.zeros([batch_size, lstm.state_size])
for i in range(num_steps):
# The value of state is updated after pr
我有一个错误 {taskinstance.py:1455} ERROR - Cannot convert a symbolic Tensor (lstm_4/strided_slice:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported 回溯(最近一次调用) 当我使用下面的代码创建LSTM-VAE模型时。 配置: Python: 3.7.9
Tensorflow: 2.4.0
NumPy: 1.1
我想在TensorFlow (Python3)中实现一个定制的LSTM或GRU单元。例如,我想在时间步骤T+1进入该单元之前,在时间步骤T中缩放来自该单元格的单元状态信号。我尝试在TensorFlow文档中搜索,但没有成功。你能给我个提示吗?谢谢。
编辑
在检查了给出的答案之后,我创建了如下模型:
def dynamic_scale_RNN(x, timescale, seqlen, weights, biases, keep_prop):
batch_size = tf.shape(x)[0]
# Unstack to get a list of 'n_steps&