Brain-tumor-segmentation
Brain-tumor-segmentation copied to clipboard
TypeError: can only concatenate list (not "int") to list
Hi, I found the TypeError while run train.py. the detail is as follows:
Traceback (most recent call last): File "train.py", line 108, in
brain_seg = Training(batch_size=4,nb_epoch=3,load_model_resume_training=model_to_load) File "train.py", line 42, in init unet =Unet_model(img_shape=(128,128,4)) File "/root/userfolder/workspace/Brain-tumor-segmentation/model.py", line 21, in init self.model =self.compile_unet() File "/root/userfolder/workspace/Brain-tumor-segmentation/model.py", line 37, in compile_unet model.compile(loss=gen_dice_loss, optimizer=sgd, metrics=[dice_whole_metric,dice_core_metric,dice_en_metric]) File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 451, in compile handle_metrics(output_metrics) File "/usr/local/lib/python3.5/dist-packages/keras/engine/training.py", line 420, in handle_metrics mask=masks[i]) File "/usr/local/lib/python3.5/dist-packages/keras/engine/training_utils.py", line 404, in weighted score_array = fn(y_true, y_pred) File "/root/userfolder/workspace/Brain-tumor-segmentation/losses.py", line 47, in dice_core_metric y_core=K.sum(y_true_f[:,[1,3]],axis=1) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/array_ops.py", line 490, in _slice_helper end.append(s + 1) TypeError: can only concatenate list (not "int") to list
I have the same error
hello I have also the same error !!!
Anyone solved it?
I solved this by using
y_core=K.sum(tf.gather(y_true_f, [1,3],axis =1),axis=1)
p_core=K.sum(tf.gather(y_pred_f, [1,3],axis =1),axis=1)
instead of
y_core=K.sum(y_true_f[:,[1,3]],axis=1)
p_core=K.sum(y_pred_f[:,[1,3]],axis=1)
in losses.py
I solved this by using
y_core=K.sum(tf.gather(y_true_f, [1,3],axis =1),axis=1) p_core=K.sum(tf.gather(y_pred_f, [1,3],axis =1),axis=1)
instead of
y_core=K.sum(y_true_f[:,[1,3]],axis=1) p_core=K.sum(y_pred_f[:,[1,3]],axis=1)
in losses.py
I'm still get the error, with Keras 2.1.5 what version you are using?