2017-05-03 19 views
2

私は現在、KerasのRui Zhangによるモデリングドキュメントの依存センシティブ畳み込みニューラルネットワークを実装しようとしています。私にとってこれはKerasで実装する最初のネットワークなので、いくつか質問しました。TimeDistributed LSTMに関する問題

DSCNN

私は、実装はかなり遠くにすでにあると思うが、モデルの初期化との大きな問題があり、次のように

ネットワークが見えます。私のミスがどこにある

Traceback (most recent call last): 
    File "/Users/peter/Masterarbeit/python-projects/dscnn-keras/classify.py", line 64, in <module> 
    model = create_model(embeddings, max_sentences_per_doc, max_sentence_len, kernel_size=[3, 4, 5], filters=100) 
    File "/Users/peter/Masterarbeit/python-projects/dscnn-keras/model.py", line 38, in create_model 
    sentence_modeling = [shared_sentence_lstm(sentence_modeling[i]) for i in range(max_sentences_per_doc)] 
    File "/Users/peter/Masterarbeit/python-projects/dscnn-keras/model.py", line 38, in <listcomp> 
    sentence_modeling = [shared_sentence_lstm(sentence_modeling[i]) for i in range(max_sentences_per_doc)] 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/engine/topology.py", line 528, in __call__ 
    self.build(input_shapes[0]) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/layers/wrappers.py", line 104, in build 
    self.layer.build(child_input_shape) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/layers/recurrent.py", line 959, in build 
    self.input_dim = input_shape[2] 
IndexError: tuple index out of range 

は、あなたが知っています:https://gist.github.com/pexmar/cec8dfdfe46b24ea7d1765f398df8d9d

以下で発生するエラー:私はその要旨を作成しましたか?

他の間違いがありますか?私は間違った行をコメントアウトした場合、私は次のエラーを取得する:最初のエラーが修正されている場合

Traceback (most recent call last): 
    File "/Users/peter/Masterarbeit/python-projects/dscnn-keras/classify.py", line 64, in <module> 
    model = create_model(embeddings, max_sentences_per_doc, max_sentence_len, kernel_size=[3, 4, 5], filters=100) 
    File "/Users/peter/Masterarbeit/python-projects/dscnn-keras/model.py", line 43, in create_model 
    sentence_modeling = [shared_sentence_lstm_2(sentence_modeling[i]) for i in range(max_sentences_per_doc)] 
    File "/Users/peter/Masterarbeit/python-projects/dscnn-keras/model.py", line 43, in <listcomp> 
    sentence_modeling = [shared_sentence_lstm_2(sentence_modeling[i]) for i in range(max_sentences_per_doc)] 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/layers/recurrent.py", line 252, in __call__ 
    return super(Recurrent, self).__call__(inputs, **kwargs) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/engine/topology.py", line 554, in __call__ 
    output = self.call(inputs, **kwargs) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/layers/recurrent.py", line 290, in call 
    preprocessed_input = self.preprocess_input(inputs, training=None) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/layers/recurrent.py", line 1033, in preprocess_input 
    return K.concatenate([x_i, x_f, x_c, x_o], axis=2) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py", line 1527, in concatenate 
    return tf.concat([to_dense(x) for x in tensors], axis) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 1075, in concat 
    dtype=dtypes.int32).get_shape(
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 669, in convert_to_tensor 
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function 
    return constant(v, dtype=dtype, name=name) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 165, in constant 
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape)) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto 
    _AssertCompatible(values, dtype) 
    File "/Users/peter/tensorflow/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible 
    (dtype.name, repr(mismatch), type(mismatch).__name__)) 
TypeError: Expected int32, got list containing Tensors of type '_Message' instead. 

それはまた起こるだろうか?ここで間違いは何ですか?

ご回答いただきありがとうございます。

答えて

0

エラーの原因が見つかりました。その位置にTimeDistributedレイヤーを適用することはできません。私はそれを通常のLSTMに置き換えなければなりませんでした。その後、それは働いた。

関連する問題