nijianmo / fit-rec

Code for WWW 19' paper
35 stars 18 forks source link

ValueError: Can not squeeze dim[2], expected a dimension of 1, got 5 #3

Open syfantid opened 1 year ago

syfantid commented 1 year ago

I am trying to run heart_rate_aux.py to reproduce your results and I am getting the following error:

Traceback (most recent call last):
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 1864, in _create_c_op
    c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Can not squeeze dim[2], expected a dimension of 1, got 5 for 'lambda_1/Squeeze_1' (op: 'Squeeze') with input shapes: [?,450,5].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\syfan\PycharmProjects\fit-rec\FitRec\heart_rate_aux.py", line 334, in <module>
    main(args)
  File "C:\Users\syfan\PycharmProjects\fit-rec\FitRec\heart_rate_aux.py", line 328, in main
    my_lstm = keras_endoLSTM(argv, newModel)
  File "C:\Users\syfan\PycharmProjects\fit-rec\FitRec\heart_rate_aux.py", line 127, in __init__
    self.model = self.build_model(args)
  File "C:\Users\syfan\PycharmProjects\fit-rec\FitRec\heart_rate_aux.py", line 150, in build_model
    user_embedding = Lambda(lambda y: K.squeeze(y, 2))(user_embedding)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\keras\engine\topology.py", line 550, in __call__
    output_shape = self.compute_output_shape(input_shape)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\keras\layers\core.py", line 627, in compute_output_shape
    x = self.call(x)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\keras\layers\core.py", line 659, in call
    return self.function(inputs, **arguments)
  File "C:\Users\syfan\PycharmProjects\fit-rec\FitRec\heart_rate_aux.py", line 150, in <lambda>
    user_embedding = Lambda(lambda y: K.squeeze(y, 2))(user_embedding)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\keras\backend\tensorflow_backend.py", line 1771, in squeeze
    return tf.squeeze(x, [axis])
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper
    return target(*args, **kwargs)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\ops\array_ops.py", line 3162, in squeeze
    return gen_array_ops.squeeze(input, axis, name)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 11642, in squeeze
    "Squeeze", input=input, squeeze_dims=axis, name=name)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
    op_def=op_def)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 3616, in create_op
    op_def=op_def)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 2027, in __init__
    control_input_ops)
  File "C:\Users\syfan\PycharmProjects\fit-rec\venv\lib\site-packages\tensorflow\python\framework\ops.py", line 1867, in _create_c_op
    raise ValueError(str(e))
ValueError: Can not squeeze dim[2], expected a dimension of 1, got 5 for 'lambda_1/Squeeze_1' (op: 'Squeeze') with input shapes: [?,450,5].

Process finished with exit code 1

The line that it refers to seems to be this one: user_embedding = Lambda(lambda y: K.squeeze(y, 2))(user_embedding)

Any ideas?

Using tensorflow==1.14.0 and keras==2.0.0 in Python 3.7 on Windows 11.