对抗生成网络无法设置其他的大小
Created by: yeyupiaoling
环境
- Ubuntu 26.04
- PaddlePaddle 1.2 GPU
问题
代码:https://github.com/yeyupiaoling/LearnPaddle2/blob/master/note13/train.py
调试方式:把包含图片文件的文件夹放在note13的datasets目录下,如note13/datasets/n02086079-Pekinese/n02086079_146.jpg
。接着执行训练程序,就会出现以下的错误,默认设置的训练图片大小为224,请问如何解决呢?
图片大小设置为32是没有问题的,超过这个就会报错,是不是我的生成器有问题,对应生成224大小的图片,应该如何修改呢?
错误信息:
Traceback (most recent call last):
File "/media/test/5C283BCA283BA1C6/yeyupiaoling/LearnPaddle2/note13/train.py", line 109, in <module>
p_fake = Discriminator(Generator(z))
File "/media/test/5C283BCA283BA1C6/yeyupiaoling/LearnPaddle2/note13/train.py", line 33, in Generator
y = deconv(x=y, num_filters=3, act='sigmoid', output_size=[image_size, image_size])
File "/media/test/5C283BCA283BA1C6/yeyupiaoling/LearnPaddle2/note13/train.py", line 19, in deconv
act=act)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layers/nn.py", line 2988, in conv2d_transpose
'use_cudnn': use_cudnn
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/layer_helper.py", line 50, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 1208, in append_op
op = Operator(block=self, desc=op_desc, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 657, in __init__
self.desc.infer_shape(self.block.desc)
paddle.fluid.core.EnforceNotMet: ConvTransposeOp output_size should be in appropriate range. at [/home/test/Downloads/Paddle/paddle/fluid/operators/conv_transpose_op.cc:70]
PaddlePaddle Call Stacks:
0 0x7f5a23450a27p paddle::platform::EnforceNotMet::EnforceNotMet(std::__exception_ptr::exception_ptr, char const*, int) + 727
1 0x7f5a23cb0549p paddle::operators::ConvTransposeOp::InferShape(paddle::framework::InferShapeContext*) const + 5241
2 0x7f5a235298a0p
3 0x7f5a2352dc5ap paddle::framework::OpDesc::InferShape(paddle::framework::BlockDesc const&) const + 1050
4 0x7f5a234d7e24p
5 0x7f5a2347f16dp
6 0x4ea137p PyCFunction_Call + 119
7 0x53c176p PyEval_EvalFrameEx + 23030
8 0x540b0bp PyEval_EvalCodeEx + 315
9 0x4ec3f7p
10 0x5c20e7p PyObject_Call + 71
11 0x4fbfcep
12 0x5c20e7p PyObject_Call + 71
13 0x574c19p
14 0x57f58cp
15 0x5c20e7p PyObject_Call + 71
16 0x538cabp PyEval_EvalFrameEx + 9515
17 0x540b0bp PyEval_EvalCodeEx + 315
18 0x4ec3f7p
19 0x5c20e7p PyObject_Call + 71
20 0x538cabp PyEval_EvalFrameEx + 9515
21 0x53fc97p
22 0x53bc93p PyEval_EvalFrameEx + 21779
23 0x53fc97p
24 0x53b83fp PyEval_EvalFrameEx + 20671
25 0x53fc97p
26 0x53b83fp PyEval_EvalFrameEx + 20671
27 0x53fc97p
28 0x53b83fp PyEval_EvalFrameEx + 20671
29 0x53fc97p
30 0x5409bfp PyEval_EvalCode + 31
31 0x60cb42p
32 0x60efeap PyRun_FileExFlags + 154
33 0x60f7dcp PyRun_SimpleFileExFlags + 444
34 0x640256p Py_Main + 1110
35 0x4d0001p main + 225
36 0x7f5a71820830p __libc_start_main + 240
37 0x5d6999p _start + 41
Process finished with exit code 1