RonLek / FastV2C-HandNet

Repository for the implementation of "FastV2C-HandNet: Fast Voxel to Coordinate Hand Pose Estimation with 3D Convolutional Neural Networks"
https://arxiv.org/abs/1907.06327
10 stars 2 forks source link

Error while run train.py #1

Closed DrhF closed 4 years ago

DrhF commented 4 years ago

Hello! I was trying to reproduce experiments with your solution. When I run train.py I have this error:

Traceback (most recent call last):
  File "train.py", line 145, in <module>
    net = model_inst(input_channels = 1, output_channels = keypoints_num) 
  File "/home/oriuser/mounted/src/mymodel.py", line 176, in model_inst
    x = Dense(44, activation = 'relu')(x) #Changed
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py", line 591, in __call__
    self._maybe_build(inputs)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/base_layer.py", line 1881, in _maybe_build
    self.build(input_shapes)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/layers/core.py", line 1005, in build
    raise ValueError('The last dimension of the inputs to `Dense` '
ValueError: The last dimension of the inputs to `Dense` should be defined. Found `None`.

I tried to fix that commenting out this line in mymodel.py

x = Reshape((output_channels, -1))(x)

And got an error:

Traceback (most recent call last):
  File "train.py", line 177, in <module>
    history = net.fit_generator(train_set, steps_per_epoch = steps_per_epoch_train, epochs = epochs_num, verbose = 1, callbacks = [cp_callback], validation_data = val_set, validation_steps = steps_per_epoch_val, workers = 0, use_multiprocessing = False, shuffle = True, initial_epoch = 0) #Changed
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 1433, in fit_generator
    steps_name='steps_per_epoch')
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training_generator.py", line 264, in model_iteration
    batch_outs = batch_function(*batch_data)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 1153, in train_on_batch
    extract_tensors_from_dataset=True)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py", line 2692, in _standardize_user_data
    y, self._feed_loss_fns, feed_output_shapes)
  File "/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training_utils.py", line 549, in check_loss_and_target_compatibility
    ' while using as loss `' + loss_name + '`. '
ValueError: A target array with shape (4, 21, 3) was passed for an output of shape (None, 21, 22, 22, 3) while using as loss `mean_squared_error`. This loss expects targets to have the same shape as the output.

Could you please specify tensorflow and keras versions? (I guess this is the issue: I use different versions of tensorflow)

If not, is there any suggestion to fix those errors?

RonLek commented 4 years ago

Hi @DrhF. Thanks for your interest in our research. Your fix to the first problem was bound to give a ValueError since the Reshape() layer shapes the output of the previous layers to have the shape (21, 22, 22, 22) (as you can see from the comment above the Reshape() line).

As for the fix to the first problem, the Reshape() layer is probably giving you the shape as (21, 22, 22, 3, None) instead of (None, 21, 22, 22, 3). Like you said, this might be due to different tensorflow and keras versions. The versions used by me are: tensorflow == 1.13.1 keras ==2.2.4

Hint: Do check out the data_format parameter in the docs for the Conv3D layer concerning channels_first and channels_last.