kaonashi-tyc / zi2zi

Learning Chinese Character style with conditional GAN
https://kaonashi-tyc.github.io/2017/04/06/zi2zi.html
Apache License 2.0
2.52k stars 470 forks source link

tensor not exist in the checkpoint pcgreat/zi2zi #66

Closed Henry658 closed 5 years ago

Henry658 commented 5 years ago

Hey guy is me again Sorry about I'm taking pcgreat/zi2zi at here Because I can't found the place to let me discuss As tittle and preamble #64 key generator/g_d1_bn/beta not found in checkpoint So I use tensorflow.python.tools inspect_checkpoint.py to watch my checkpoint And I compared the pcgreat/zi2zi model and kaonashi-tyc/zi2zi model with the checkpoint

Screen Shot 2019-04-13 at 2 41 13 AM

left is pcgreat/zi2zi right is kaonashi-tyc/zi2zi And you can see some tensor is not exist in the pcgreat/zi2zi checkpoint I was wondering if someone can tell me and fix it

the same as past I and still try to solve this problem This is my contact information. mail: henry19980520@gmail.com I look forward to discussing with you.

jerrycheese commented 5 years ago

这是因为train.py和infer.py的inst_norm参数不一样导致的。

可以看到train.py的初始化参数inst_norm参数默认为1,而infer.py该参数默认为0,将其改为1即可,差别可见: model/unet.py#L114

除了这个问题以外,也许还会遇到:

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [80,1,1,64] rhs shape= [185,1,1,128]

因为UNet的embedding数量、大小不一样,对应train.py的embedding_numembedding_dim参数,将其应用到infer.py就行,可见:/train.py#L24

以及这个问题:

ValueError: Cannot feed value of shape (16, 256, 256, 2) for Tensor 'real_A_and_B_images:0', which has shape '(?, 128, 128, 2)'

这是因为两个文件的image_size不一样,根据train.py的参数应用到infer.py就行了,可见:/train.py#L17

Henry658 commented 5 years ago

thanks 很感謝你的回覆 接下來還可能有問題要請教您 方便留下信箱向您詢問嗎? 這是我的信箱:henry19980520@gmail.com 謝謝

Danee-wawawa commented 4 years ago

这是因为train.py和infer.py的inst_norm参数不一样导致的。

可以看到train.py的初始化参数inst_norm参数默认为1,而infer.py该参数默认为0,将其改为1即可,差别可见: model/unet.py#L114

除了这个问题以外,也许还会遇到:

InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [80,1,1,64] rhs shape= [185,1,1,128]

因为UNet的embedding数量、大小不一样,对应train.py的embedding_numembedding_dim参数,将其应用到infer.py就行,可见:/train.py#L24

以及这个问题:

ValueError: Cannot feed value of shape (16, 256, 256, 2) for Tensor 'real_A_and_B_images:0', which has shape '(?, 128, 128, 2)'

这是因为两个文件的image_size不一样,根据train.py的参数应用到infer.py就行了,可见:/train.py#L17

谢谢你的回答,这些帮助了我很多。另外我在训练模型结束后,进行fine tune时,遇到了一个问题,当我运行:

Train/Finetune the model

PYTHONPATH=. python train.py --experiment_dir=experiments_finetune \ --experiment_id=0 \ --batch_size=16 \ --lr=0.001 \ --epoch=10 \ --sample_steps=1 \ --schedule=20 \ --L1_penalty=100 \ --Lconst_penalty=15 \ --freeze_encoder_decoder=1 \ --optimizer=sgd \ --fine_tune=67 \ --flip_labels=1 这个指令时,出现: filter by label -> {67} train examples -> 0, val examples ->0 这个信息,它好像把我所有样本都给筛选掉了,我用的是他这个里面的handwriting_preparation/images/test_image.img 和 .box,我不清楚问题在哪里,不知道你有没有遇到过这个问题呢~

Henry658 commented 4 years ago

你必須將你的訓練集放入finetune資料夾中的data 也就是說你原本將訓練集pair圖片打包成train.obj及val.obj並放至於experiment中的data folder中 而你現在要使用finetune也需要將你的train.obj及val.obj放入experiment_finetune中的data folder 看起來就是這樣

Danee-wawawa commented 4 years ago

你必須將你的訓練集放入finetune資料夾中的data 也就是說你原本將訓練集pair圖片打包成train.obj及val.obj並放至於experiment中的data folder中 而你現在要使用finetune也需要將你的train.obj及val.obj放入experiment_finetune中的data folder 看起來就是這樣

我的experiments_finetune/data/里面有对应的train.obj及val.obj,它完整的运行显示是: unpickled total 142 examples unpickled total 14 examples filter by label -> {67} train examples -> 0, val examples ->0 所以应该是已经读取到了train.obj和val.obj,但是我不清楚为什么又全部会被filter掉,请问下您没有遇到这个问题吗~

Henry658 commented 4 years ago

你的obj檔中是否有包含embeddiing_id 67 我假設67是你準備得手寫資料,假設你的obj是由experiment所複製過來的 這樣67在當初package時是沒有包含在embedding中的 你需另外package 你的字體及手寫資料

Danee-wawawa commented 4 years ago

你的obj檔中是否有包含embeddiing_id 67 我假設67是你準備得手寫資料,假設你的obj是由experiment所複製過來的 這樣67在當初package時是沒有包含在embedding中的 你需另外package 你的字體及手寫資料

对的,我明白问题在哪里了,刚刚解决啦,非常感谢^_^

Henry658 commented 4 years ago

好的! 以前我也是這樣受大家的幫忙才能夠理解、除錯。 這是我的信箱:henry19980520@gmail.com 如果有問題也歡迎詢問。

Danee-wawawa commented 4 years ago

好的! 以前我也是這樣受大家的幫忙才能夠理解、除錯。 這是我的信箱:henry19980520@gmail.com 如果有問題也歡迎詢問。

好的,之后遇到问题我再发邮箱问您,谢谢~^_^