u-net icon indicating copy to clipboard operation
u-net copied to clipboard

InvalidArgumentError (see above for traceback): Incompatible shapes: [1146880] vs. [158720]

Open Bananaboy99 opened this issue 7 years ago • 1 comments

I´m trying to run the Network but always running into the Error below:

Caused by op 'mul', defined at:
  File "train.py", line 206, in <module>
    train_and_predict()
  File "train.py", line 153, in train_and_predict
    model = get_unet()
  File "train.py", line 115, in get_unet
    model.compile(optimizer=Adam(lr=1e-5), loss=dice_coef_loss, metrics=[dice_coef])
  File "/usr/lib64/python3.4/site-packages/keras/engine/training.py", line 899, in compile
    sample_weight, mask)
  File "/usr/lib64/python3.4/site-packages/keras/engine/training.py", line 430, in weighted
    score_array = fn(y_true, y_pred)
  File "train.py", line 30, in dice_coef_loss
    return 1.-dice_coef(y_true, y_pred)
  File "train.py", line 25, in dice_coef
    intersection = K.sum(y_true_f * y_pred_f)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/ops/math_ops.py", line 794, in binary_op_wrapper
    return func(x, y, name=name)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/ops/math_ops.py", line 1015, in _mul_dispatch
    return gen_math_ops._mul(x, y, name=name)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/ops/gen_math_ops.py", line 1625, in _mul
    result = _op_def_lib.apply_op("Mul", x=x, y=y, name=name)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
    op_def=op_def)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/usr/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 1226, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Incompatible shapes: [1146880] vs. [158720]
	 [[Node: mul = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/gpu:0"](Reshape, Reshape_1)]]
	 [[Node: mul_5/_29 = _Recv[client_terminated=false, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/gpu:0", send_device_incarnation=1, tensor_name="edge_3199_mul_5", tensor_type=DT_FLOAT, _device="/job:localhost/replica:0/task:0/cpu:0"]()]]

At line 25 it has a problem with calculating intersection = K.sum(y_true_f * y_pred_f

Where is y_true and y_pred defined??

Thanks for the help.

Bananaboy99 avatar Apr 28 '17 08:04 Bananaboy99

y_true and y_pred are parameters

ethanhe42 avatar May 09 '17 06:05 ethanhe42