- 줄리아 0.6.0
- TensorFlow.jl 0.7.5
- tensorflow (파이썬) 1.4.1
- OS : 우분투 16.04
내가 시계열 예측을위한 LSTM 설정 마지막 타임 스텝뿐만 아니라 손실을 계산할 때마다 모든 타임 스텝마다 출력이 필요합니다. documentation of tensorflow (Python API)에 따르면 dynamic_rnn
의 출력은 [batch_size, max_time, cell.output_size]
(time_major == False
인 경우) 모양이어야합니다. 파이썬에서TensorFlow.jl의 출력 형상
이 잘 작동합니다 :
import tensorflow as tf
import numpy as np
batch_size = 3
series_length = 10
hidden_size = 7
number_of_features = 2
session = tf.Session()
x = tf.placeholder(tf.float32, [None, series_length, number_of_features])
cell = tf.contrib.rnn.BasicLSTMCell(hidden_size)
outputs, state = tf.nn.dynamic_rnn(cell, x, dtype=tf.float32)
session.run(tf.global_variables_initializer())
o = session.run(outputs, feed_dict={x: np.random.randn(batch_size, series_length, number_of_features)})
outputs
는 [batch_size, series_length, hidden_size]
에 동의 [3, 10, 7]
을 형성있다.
이제 밀도 단계를 사용하여 매 시간 단계마다 단일 값 y를 출력 할 수 있습니다.
TensorFlow.jl을 사용할 때 [batch_size, hidden_size]
에 해당하는 [3, 7]
의 모양을 가지고 있습니다. 이것은 마지막 시간 단계 인 것 같습니다.
using TensorFlow
tf = TensorFlow
batch_size = 3
series_length = 10
number_of_features = 2
hidden_size = 7
session = tf.Session()
x = tf.placeholder(Float32, shape=[-1, series_length, number_of_features])
cell = tf.nn.rnn_cell.LSTMCell(hidden_size)
outputs, state = tf.nn.dynamic_rnn(cell, x)
run(session, global_variables_initializer())
o = run(session, [outputs], Dict(x=>rand(Float32, batch_size, series_length, number_of_features)))
누군가가 의도적으로 의도했는지, 버그인지, 누락 되었습니까?