简体   繁体   English

如何解决 pytorch 程序的问题?

[英]How can I solve the problem of pytorch program?

I want to run python program using pytorch with my own dataset.I come across with the error: Traceback (most recent call last): File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 345, in fire.Fire(demo) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py", line 468, in _Fire target=component.我想使用 pytorch 和我自己的数据集运行 python 程序。我遇到了错误:Traceback(最近一次调用最后一次):文件“C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py”,第 345 行,在 fire.Fire(demo) 文件“C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py”中,第 138 行,在 Fire component_trace = _Fire(component, args , parsed_flag_args, context, name) 文件“C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py”,第 468 行,在 _Fire 目标 = 组件中。 name ) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py", line 672, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 323, in demo n_epochs=n_epochs, batch_size=batch_size, seed=seed) File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 202, in train n_epochs=n_epochs, File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py", line 83, in train_epoch output = model(input) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Downloads\efficient_densenet_pytorch-master\models\densenet.py", line 151, in forward features = self.features(x) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\U名称)文件“C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\fire\core.py”,第 672 行,_CallAndUpdateTrace 组件 = fn(*varargs, **kwargs) 文件“ C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py",第 323 行,在演示 n_epochs=n_epochs,batch_size=batch_size,seed=seed) 文件“C:\Users\hp\Downloads\efficient_densenet_pytorch-master\ demoEmotion.py”,第 202 行,在火车 n_epochs=n_epochs,文件“C:\Users\hp\Downloads\efficient_densenet_pytorch-master\demoEmotion.py”,第 83 行,在 train_epoch output = 模型(输入)文件“C:\ Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py”,第 555 行,调用结果 = self.forward(*input, **kwargs) 文件“C :\Users\hp\Downloads\efficient_densenet_pytorch-master\models\densenet.py”,第 151 行,前向 features = self.features(x) 文件“C:\Users\hp\Anaconda3\envs\tf-gpu\lib \site-packages\torch\nn\modules\module.py",第 555 行,调用结果 = self.forward(*input, **kwargs) 文件“C:\U sers\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\container.py", line 100, in forward input = module(input) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\container.py", line 100, in forward input = module(input) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py", line 555, in call result = self.forward(*input, **kwargs) File "C:\Users\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\pooling.py", line 557, in forward self.padding, self.ceil_mode, self.count_include_pad, self.divisor_override) RuntimeError: Given input size: (150x1x1). sers\hp\Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\container.py”,第 100 行,前向输入 = 模块(输入)文件“C:\Users\hp\Anaconda3 \envs\tf-gpu\lib\site-packages\torch\nn\modules\module.py”,第 555 行,调用结果 = self.forward(*input, **kwargs) 文件“C:\Users\hp \Anaconda3\envs\tf-gpu\lib\site-packages\torch\nn\modules\container.py”,第 100 行,前向输入 = 模块(输入)文件“C:\Users\hp\Anaconda3\envs\ tf-gpu\lib\site-packages\torch\nn\modules\module.py”,第 555 行,调用结果 = self.forward(*input, **kwargs) 文件“C:\Users\hp\Anaconda3\ envs\tf-gpu\lib\site-packages\torch\nn\modules\pooling.py",第 557 行,前向 self.padding、self.ceil_mode、self.count_include_pad、self.divisor_override) RuntimeError:给定输入大小: (150x1x1)。 Calculated output size: (150x0x0).计算出的 output 大小:(150x0x0)。 Output size is too small Please guide me how to sove this problem.Thanks in advance! Output 尺寸太小请指导我如何解决此问题。提前致谢!

Please check the input size of the image.请检查图像的输入尺寸。 It has to be exactly the same as specified in the model.它必须与 model 中的规定完全相同。 You can use padding if the image is smaller.如果图像较小,您可以使用填充。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM