kylekma / X2CT

GNU Lesser General Public License v3.0
143 stars 48 forks source link

使用基线DCNN训练 #20

Closed Floyd809 closed 2 years ago

Floyd809 commented 2 years ago

尝试使用singleXray3DVolumes.py进行训练 报错如下,请问如何解决?谢谢!

============================== ====YAML Parameters MODEL_SAVE_PATH: /media/ihavc05/DATA/LiGen/CT2X_project/X2CT-master-1/3DGAN/save_models CT_MIN_MAX: [0, 2500] XRAY1_MIN_MAX: [0, 255] XRAY2_MIN_MAX: [0, 255] CT_MEAN_STD: [0.0, 1.0] XRAY1_MEAN_STD: [0.0, 1.0] XRAY2_MEAN_STD: [0.0, 1.0] input_nc_G: 512 output_nc_G: 1 ngf: 64 which_model_netG: singleview_2D norm_G: instance3d no_dropout: True init_type: normal ganloss: lsgan n_downsampling: 4 n_blocks: 1 activation_type: relu input_nc_D: 1 ndf: 64 which_model_netD: basic3d n_layers_D: 3 norm_D: instance3d n_out_ChannelsD: 1 pool_size: 50 if_pool: False num_D: 3 conditional_D: True map_input_nc_D: 1 map_ndf: 64 map_which_model_netD: multi2d map_n_layers_D: 3 map_norm_D: instance map_n_out_ChannelsD: 1 map_pool_size: 50 map_num_D: 3 lr: 0.0002 beta1: 0.5 beta2: 0.99 serial_batches: False batch_size: 4 nThreads: 5 lr_policy: lambda niter: 50 niter_decay: 50 lr_decay_iters: 50 print_freq: 10 print_img_freq: 500 save_latest_freq: 1000 save_epoch_freq: 10 begin_save_epoch: 0 weight_decay_if: False howmany_in_train: 10 select_slice_num: 0 fine_size: 128 ct_channel: 128 xray_channel: 1 resize_size: 150 idt_lambda: 10.0 idt_reduction: elementwise_mean idt_weight: 0.0 idt_weight_range: [0.0, 1.0] restruction_loss: mse fea_m_lambda: 10.0 discriminator_feature: False wgan_gp_lambda: 10.0 map_m_lambda: 0.0 map_m_type: l1 fea_m_map_lambda: 10.0 critic_times: 1 noise_len: 1000 input_shape: [4, 4, 4] output_shape: [128, 128, 128] encoder_input_shape: [128, 128] encoder_input_nc: 1 encoder_norm: instance encoder_blocks: 3 multi_view: [1, 2, 3] min_max_norm: True skip_number: 1 dblu: [0.0, 1.0, 1.0] Xray1_Direction: HDW Xray2_Direction: WDH CTOrder: [0, 1, 2, 3, 4] CTOrder_Xray1: [0, 1, 3, 2, 4] CTOrder_Xray2: [0, 1, 4, 2, 3] idt_loss: mse feature_D_lambda: 0.0 map_projection_lambda: 10.0 map_projection_loss: l1 gan_lambda: 0.1 auxiliary_lambda: 0.0 auxiliary_loss: mse feature_D_map_lambda: 0.0 map_gan_lambda: 1.0 data: LIDC256 tag: d2_singleview2500 dataroot: ./data/LIDC-HDF5-256 dataset: train valid_dataset: test datasetfile: ./data/train.txt valid_datasetfile: ./data/test.txt ymlpath: ./experiment/singleview2500/d2_singleview2500.yml gpuid: 0 dataset_class: align_ct_xray_std model_class: SingleViewED check_point: None load_path: None latest: False verbose: False gpu_ids: [0] epoch_count: 1

Valid DataSet is AlignDataSet

validation images = 102

DataSet is AlignDataSet

training images = 229

Model --singleView_xray2D-- will be Used initialize network parameters with normal ---------- Networks initialized ------------- [Network G] Total number of parameters : 9.068 M

UserWarning: Using a target size (torch.Size([4, 128, 128, 128])) that is different to the input size (torch.Size([4, 64, 128, 64])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size. mse = F.mse_loss(tensorA, tensorB) Traceback (most recent call last): File "/media/DATA/CT2X_project/X2CT-master-1/3DGAN/train.py", line 147, in gan_model.optimize_parameters() File "/media/DATA/CT2X_project/X2CT-master-1/3DGAN/lib/model/singleView_xray.py", line 161, in optimize_parameters self() File "/home/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1051, in _call_impl return forward_call(*input, **kwargs) File "/media/DATA/CT2X_project/X2CT-master-1/3DGAN/lib/model/singleView_xray.py", line 157, in forward self.metrics_evaluation() File "/media//DATA/CT2X_project/X2CT-master-1/3DGAN/lib/model/singleView_xray.py", line 136, in metrics_evaluation self.metrics_Mse = Metrics.Mean_Squared_Error(g_fake_unNorm, g_real_unNorm) File "/media/DATA/CT2X_project/X2CT-master-1/3DGAN/lib/utils/metrics.py", line 26, in Mean_Squared_Error mse = F.mse_loss(tensorA, tensorB) File "/home/anaconda3/envs/py37/lib/python3.7/site-packages/torch/nn/functional.py", line 3089, in mse_loss expanded_input, expanded_target = torch.broadcast_tensors(input, target) File "/home/anaconda3/envs/py37/lib/python3.7/site-packages/torch/functional.py", line 73, in broadcast_tensors return _VF.broadcast_tensors(tensors) # type: ignore[attr-defined] RuntimeError: The size of tensor a (64) must match the size of tensor b (128) at non-singleton dimension 3

尝试使用singleXray3DVolumes.py进行训练 报错如上,请问如何解决?谢谢!

yinyin-llll commented 1 year ago

你好,请问你是咋训练的,为什么我用了命令后程序一点反应都没有 image