This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
To run the CPU benchmark: `CUDA_VISIBLE_DEVICES="" python benchmark.py --name cpu` | |
To run the GPU benchmark: `CUDA_VISIBLE_DEVICES=0 python benchmark.py --name cuda` | |
To run the distributed benchmark: `python -u -m torch.distributed.launch --nproc_per_node=2 --use_env benchmark.py --name dist` | |
''' | |
import argparse | |
import time | |
import math |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import torch | |
def tfm2theta_2d(tfm, h, w): | |
"""Returns theta for affine_grid""" | |
theta = tfm.new_zeros((tfm.size(0), 2, 3)) | |
theta[:,0,0] = tfm[:,0,0] | |
theta[:,0,1] = tfm[:,0,1]*h/w | |
theta[:,0,2] = tfm[:,0,2]*2/w + tfm[:,0,0] + tfm[:,0,1] - 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import torch | |
from torch import nn | |
import torchvision | |
from torchvision import transforms | |
from ignite.metrics import Accuracy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import torch | |
from torch import nn | |
import torchvision | |
from torchvision import transforms | |
from ignite.metrics import Accuracy |