ronghanghu / cmn

Code release for Hu et al. Modeling Relationships in Referential Expressions with Compositional Modular Networks. in CVPR, 2017
http://ronghanghu.com/cmn/
Other
67 stars 18 forks source link

Error with tensorflow 1.2.1 #2

Open kylemin opened 7 years ago

kylemin commented 7 years ago

If I try to train the model on Visual Genome, this error occurs. (tensorflow 1.2.1)

Traceback (most recent call last):
  File "./exp-visgeno-rel/exp_train_visgeno_attbilstm_strong.py", line 65, in 
    text_seq_batch, num_vocab, embed_dim, lstm_dim, vgg_dropout, lstm_dropout)
  File "/mnt/brain1/scratch/kylemin/object_detection/cmn/models/visgeno_attention_model.py", line 23, in visgeno_attbilstm_net
    lstm_dim=lstm_dim, apply_dropout=lstm_dropout)
  File "/mnt/brain1/scratch/kylemin/object_detection/cmn/models/lstm_net.py", line 46, in attbilstm
    scope="bidirectional_lstm2")
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 375, in bidirectional_dynamic_rnn
    time_major=time_major, scope=fw_scope)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 574, in dynamic_rnn
    dtype=dtype)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 737, in _dynamic_rnn_loop
    swap_memory=swap_memory)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2770, in while_loop
    result = context.BuildLoop(cond, body, loop_vars, shape_invariants)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2599, in BuildLoop
    pred, body, original_loop_vars, loop_vars, shape_invariants)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/control_flow_ops.py", line 2549, in _BuildLoop
    body_result = body(*packed_vars_for_body)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 720, in _time_step
    skip_conditionals=True)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 206, in _rnn_step
    new_output, new_state = call_cell()
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn.py", line 708, in 
    call_cell = lambda: cell(input_t, state)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 180, in __call__
    return super(RNNCell, self).__call__(inputs, state)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 441, in __call__
    outputs = self.call(inputs, *args, **kwargs)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 383, in call
    concat = _linear([inputs, h], 4 * self._num_units, True)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 1017, in _linear
    initializer=kernel_initializer)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 1065, in get_variable
    use_resource=use_resource, custom_getter=custom_getter)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 962, in get_variable
    use_resource=use_resource, custom_getter=custom_getter)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 360, in get_variable
    validate_shape=validate_shape, use_resource=use_resource)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/rnn_cell_impl.py", line 183, in _rnn_get_variable
    variable = getter(*args, **kwargs)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 352, in _true_getter
    use_resource=use_resource)
  File "/mnt/brain1/scratch/kylemin/anaconda/lib/python3.6/site-packages/tensorflow/python/ops/variable_scope.py", line 669, in _get_single_variable
    found_var.get_shape()))
ValueError: Trying to share variable lstm/bidirectional_lstm1/fw/basic_lstm_cell/kernel, but specified shape (3000, 4000) and found shape (1300, 4000).

Thank you.

Kenneth-Wong commented 7 years ago

You may have a try: change the original "lstm_cell = tf.contrib.rnn.BasicLSTMCell(lstm_dim, state_is_tuple=True) outputs2raw, = tf.nn.bidirectional_dynamic_rnn(lstm_cell, lstm_cell, outputs1, seq_length, dtype=tf.float32, time_major=True, scope="bidirectional_lstm2")" into “lstm_cell_2 = tf.contrib.rnn.BasicLSTMCell(lstm_dim, state_is_tuple=True) outputs2raw, = tf.nn.bidirectional_dynamic_rnn(lstm_cell_2, lstm_cell_2, outputs1, seq_length, dtype=tf.float32, time_major=True, scope="bidirectional_lstm2")”

It works for me.