2017-01-13 12 views
1

ダイナミック軸に関する多くの問題が発生しています。私は、LSTM()関数と同様の畳み込みrnnを実装しようとしていますが、連続した画像の入力と出力を処理します。カスタムRNNを使用したダイナミック軸

私はネットワークを構築し、出力を生成するためにそれを介してダミーデータを渡すことができんだけど、私は一貫して、次のエラーが表示さinput_variableラベルで誤差を計算しようとすると:

RuntimeError: Node '__v2libuid__Input471__v2libname__img_label' (InputValue operation): DataFor: FrameRange's dynamic axis is inconsistent with matrix: {numTimeSteps:1, numParallelSequences:2, sequences:[{seqId:0, s:0, begin:0, end:1}, {seqId:1, s:1, begin:0, end:1}]} vs. {numTimeSteps:2, numParallelSequences:1, sequences:[{seqId:0, s:0, begin:0, end:2}]}` 

た場合、私はこのエラーメッセージを正しく理解していれば、ラベルとして渡された値が、2つのタイムステップと1つのパラレルシーケンスで予想される軸に一貫性のない軸を持ち、1つのタイムステップと2つのシーケンスが望ましい場合。これは私には意味がありますが、私が渡しているデータがどのようにこれに準拠していないのか分かりません。

… 
img_input = input_variable(shape=img_shape, dtype=np.float32, name="img_input") 
convlstm = Recurrence(conv_lstm_cell, initial_state=initial_state)(img_input) 
out = select_last(convlstm) 
img_label = input_variable(shape=img_shape, dynamic_axes=out.dynamic_axes, dtype=np.float32, name="img_label”) 
error = squared_error(out, img_label) 
… 

dummy_input = np.ones(shape=(2, 3, 3, 32, 32)) # (batch, seq_len, channels, height, width) 
dummy_label = np.ones(shape=(2, 3, 32, 32))  # (batch, channels, height, width) 
out = error.eval({img_input:dummy_input, img_label:dummy_label}) 

私は問題の一部は、img_labelのinput_variableを作成するときに設定dynamic_axesであり、私も[Axis.default_batch_axis(にそれを設定しようとしたと考えている):ここでは(おおよそ)変数宣言とはevalステートメントです]とそれをまったく設定していないと、二乗誤差はoutとimg_labelの軸の不一致について不平を言うか、上記と同じエラーが表示されます。

答えて

0

私は上記のセットアップを参照して唯一の問題は、それがLSTMに似ごconvlstm作品、次の作品を想定し

dummy_label = np.ones(shape=(2, 1, 3, 32, 32)) 

として宣言する必要がありますので、あなたのダミーラベルは、明示的な動的な軸を持つべきであるということです2つの入力/出力ペアの損失を評価します。

x = C.input_variable((3,32,32)) 
cx = convlstm(x) 
lx = C.sequence.last(cx) 
y = C.input_variable(lx.shape, dynamic_axes=lx.dynamic_axes) 
loss = C.squared_error(y, lx) 
x0 = np.arange(2*3*3*32*32,dtype=np.float32).reshape(2,3,3,32,32) 
y0 = np.arange(2*1*3*32*32,dtype=np.float32).reshape(2,1,3,32,32) 
loss.eval({x:x0, y:y0}) 
関連する問題