xamyzhao / brainstorm

Implementation of "Data augmentation using learned transforms for one-shot medical image segmentation"
MIT License
392 stars 91 forks source link

ValueError #7

Closed Lzf-Peter closed 5 years ago

Lzf-Peter commented 5 years ago

Hi, thanks for your excellent work. But when I run python main.py trans --gpu 0 --data mri-100unlabeled --model flow-fwd by default, there are following errors. ValueError: Error when checking target: expected flow to have shape (None, 160, 192, 224, 3) but got array with shape (1, 160, 192, 224, 1)

xamyzhao commented 5 years ago

@Lzf-Peter I am unable to reproduce your issue. Can you please make sure you've pulled the latest version of the code? Thanks.

Lzf-Peter commented 5 years ago

I try to pull the latest version of the code, but there are same error. Traceback (most recent call last): File "/home/liu/brainstorm/main.py", line 357, in test_every_n_epochs=test_every_n_epochs) File "/home/liu/brainstorm/src/experiment_engine.py", line 133, in run_experiment run_metadata=None, File "/home/liu/brainstorm/src/experiment_engine.py", line 184, in train_batch_by_batch joint_loss, joint_loss_names = exp.train_on_batch() File "/home/liu/brainstorm/src/transform_models.py", line 589, in train_on_batch loss_vals = self.transform_model.train_on_batch(X, Y) File "/home/liu/anaconda2/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 1808, in train_on_batch check_batch_axis=True) File "/home/liu/anaconda2/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 1411, in _standardize_user_data exception_prefix='target') File "/home/liu/anaconda2/envs/py36/lib/python3.6/site-packages/keras/engine/training.py", line 153, in _standardize_input_data str(array.shape)) ValueError: Error when checking target: expected flow to have shape (None, 160, 192, 224, 3) but got array with shape (1, 160, 192, 224, 1)

xamyzhao commented 5 years ago

@Lzf-Peter unfortunately I am still not able to repro your issue in the latest version of the code, even in a new directory. I would recommend pulling the code and following the setup instructions again in a new directory. Alternatively, it looks the issue is simply that the targets being fed to the network at train time are in the wrong order -- you could check that the batch generator is producing targets in the order expected by the flow network.

Lzf-Peter commented 5 years ago

the shape of the batch produced by batch generator should be (160,192,224,1) or (160,192,224,3)?

xamyzhao commented 5 years ago

@Lzf-Peter since I'm not sure which version of the code you are using, you should check on the network architecture yourself. The flow network is defined in create_models() in transform_models.py. You should be able to look at the order of the outputs to determine the desired shapes -- the transformed volume should be (160, 192, 224, 1), while the output flow should be (160, 192, 224, 3).

Lzf-Peter commented 5 years ago

Ok,thank you for your explanation.

发自我的iPhone

------------------ Original ------------------ From: xamyzhao notifications@github.com Date: Tue,Jun 11,2019 0:04 AM To: xamyzhao/brainstorm brainstorm@noreply.github.com Cc: Lzf-Peter 734165132@qq.com, Mention mention@noreply.github.com Subject: Re: [xamyzhao/brainstorm] ValueError (#7)