Repository: pytorch
Issue: RuntimeError: Given input size: (2048x1x1). Calculated output size: (2048x-5x-5). Output size is too small at /pytorch/aten/src/THNN/generic/SpatialAveragePooling.c:48
Labels: module: docs,triaged,module: tensorboard,has workaround

```
import torch
import torchvision
from torch.utils.tensorboard import SummaryWriter
from torchvision import datasets, transforms
```

  # Writer will output to ./runs/ directory by default
```
writer = SummaryWriter()

transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5,), (0.5,))])
trainset = datasets.MNIST('mnist', train=True, download=True, transform=transform)
trainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)
model = torchvision.models.resnet50(False)
  # Have ResNet model take in grayscale rather than RGB
model.conv1 = torch.nn.Conv2d(1, 64, kernel_size=7, stride=2, padding=3, bias=False)
images, labels = next(iter(trainloader))
grid = torchvision.utils.make_grid(images)
writer.add_image('images', grid, 0)
writer.add_graph(model, images)
writer.close()

```

> Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
> Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
> Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
> Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
> Processing...
> Done!
> Error occurs, No graph saved
> Traceback (most recent call last):
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/utils/tensorboard/_pytorch_graph.py", line 276, in graph
>     trace, _ = torch.jit.get_trace_graph(model, args)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/jit/__init__.py", line 231, in get_trace_graph
>     return LegacyTracedModule(f, _force_outplace, return_inputs)(*args, **kwargs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
>     result = self.forward(*input, **kwargs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/jit/__init__.py", line 294, in forward
>     out = self.inner(*trace_inputs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
>     result = self._slow_forward(*input, **kwargs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 481, in _slow_forward
>     result = self.forward(*input, **kwargs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torchvision/models/resnet.py", line 149, in forward
>     x = self.avgpool(x)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in __call__
>     result = self._slow_forward(*input, **kwargs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 481, in _slow_forward
>     result = self.forward(*input, **kwargs)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/pooling.py", line 563, in forward
>     self.padding, self.ceil_mode, self.count_include_pad)
> RuntimeError: Given input size: (2048x1x1). Calculated output size: (2048x-5x-5). Output size is too small at /pytorch/aten/src/THNN/generic/SpatialAveragePooling.c:48

During handling of the above exception, another exception occurred:

> Traceback (most recent call last):
>   File "/home/tian/pycharm-2018.3.3/helpers/pydev/pydevd.py", line 1741, in <module>
>     main()
>   File "/home/tian/pycharm-2018.3.3/helpers/pydev/pydevd.py", line 1735, in main
>     globals = debugger.run(setup['file'], None, None, is_module)
>   File "/home/tian/pycharm-2018.3.3/helpers/pydev/pydevd.py", line 1135, in run
>     pydev_imports.execfile(file, globals, locals)  # execute the script
>   File "/home/tian/pycharm-2018.3.3/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
>     exec(compile(contents+"\n", file, 'exec'), glob, loc)
>   File "/home/tian/Desktop/ai/machine-learn/Image_recognition/tensorboard_test.py", line 18, in <module>
>     writer.add_graph(model, images)
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/utils/tensorboard/writer.py", line 534, in add_graph
>     self._get_file_writer().add_graph(graph(model, input_to_model, verbose, **kwargs))
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/utils/tensorboard/_pytorch_graph.py", line 279, in graph
>     _ = model(*args)  # don't catch, just print the error message
>   File "/home/tian/.conda/envs/jiqi/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in __call__
>     result = self.forward(*input, **kwargs)
> TypeError: forward() takes 2 positional arguments but 65 were given

- 
![2019-05-06 14-14-41 的屏幕截图](https://user-images.githubusercontent.com/37957822/57209028-52579980-7009-11e9-9e16-4c694ae08c33.png)