Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: can only concatenate list (not "int") to list #7

Open
chengjianhong opened this issue Dec 12, 2018 · 5 comments
Open

TypeError: can only concatenate list (not "int") to list #7

chengjianhong opened this issue Dec 12, 2018 · 5 comments

Comments

@chengjianhong
Copy link

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

@shaktichetan
Copy link

I have the same error

@takrouni
Copy link

takrouni commented Feb 6, 2019

hello
I have also the same error !!!

@muween
Copy link

muween commented Apr 30, 2019

Anyone solved it?

@muween
Copy link

muween commented Apr 30, 2019

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

@gusleo
Copy link

gusleo commented Sep 30, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants