-1
私は言語モデルのRNNを勉強していて、Tensorflowでそのコードを本に見つけました。 しかし、私は実際にx[:t:]
が以下のコードで何をするのか分かりません..... 私は機械学習の初心者です。もし誰かが知っていれば、私に手がかりを与えてください。Pythonでx [:t:]は何をしますか? <RNN>
=======コード========
def inference(x, n_batch, maxlen=None, n_hidden=None, n_out=None):
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.01)
return tf.Variable(initial)
def bias_variable(shape):
initial = tf.zeros(shape, dtype=tf.float32)
return tf.Variable(initial)
cell = tf.contrib.rnn.BasicRNNCell(n_hidden)
initial_state = cell.zero_state(n_batch, tf.float32)
state = initial_state
outputs = []
with tf.variable_scope('RNN'):
for t in range(maxlen):
if t > 0:
tf.get_variable_scope().reuse_variables()
(cell_output, state) = cell(x[:, t, :], state)
outputs.append(cell_output)
output = outputs[-1]
V = weight_variable([n_hidden, n_out])
c = bias_variable([n_out])
y = tf.matmul(output, V) + c
return y
x [:t:]またはx [:, t、:]? – ingvar
これはあなたが提供しなかった 'x'のタイプに完全に依存します。 – timgeb
@timgeb - タグに基づいて、テンソルフローテンソル(これは数が少ない配列のように多く動作する)がほぼ確実であると確信しています。 – mgilson