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()
This can then be visualized with TensorBoard, which should be
installable and runnable with:
pip install tensorboard
   tensorboard --logdir=runs
Lots of information can be logged for one experiment. To avoid
cluttering the UI and have better result clustering, we can group
plots by naming them hierarchically. For example, "Loss/train" and
"Loss/test" will be grouped together, while "Accuracy/train" and
"Accuracy/test" will be grouped separately in the TensorBoard
interface.
from torch.utils.tensorboard import SummaryWriter
   import numpy as np