This file contains hidden or 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
Code to test: | |
x = torch.randint(2, (1000, 1000)) | |
torch_times = {} | |
torch_tmp = [] | |
for dim in range(2): | |
for _ in range(10): | |
t0 = time.perf_counter() | |
tu, ti = torch.unique(x, return_inverse=True, dim=dim) |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Dec 21 19:26:32 2018 | |
@author: ptrblck | |
""" | |
import torch | |
import numpy as np |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
batch_size = 10 | |
channels = 3 | |
h, w = 16, 16 | |
x = torch.randn(batch_size, channels, h, w) | |
pool = nn.AvgPool2d((1, 2), (1, 2)) |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
import torch.optim as optim | |
from torch.utils.data import Dataset, DataLoader | |
device = 'cpu' | |
class MyDataset(Dataset): |
This file contains hidden or 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
conda create -n pytorch4 python=3.6 | |
conda activate pytorch4 | |
conda install pytorch=0.4.0 torchvision -c pytorch | |
pip install requests dominate | |
conda install opencv pillow scipy |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
import torch.optim as optim | |
from torch.utils.data import Dataset, DataLoader | |
import torchvision.models as models | |
import torchvision.transforms as transforms | |
# Use standard model with [batch_size, 3, 224, 224] input |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
torch.manual_seed(2809) | |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
import torch.optim as optim | |
import torch.nn.functional as F | |
from torch.utils.data import DataLoader | |
import torchvision.transforms as transforms | |
import torchvision.datasets as datasets | |
import matplotlib.pyplot as plt |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
class UNet_down_block(torch.nn.Module): | |
def __init__(self, input_channel, output_channel, down_size): | |
super(UNet_down_block, self).__init__() | |
self.conv1 = torch.nn.Conv2d(input_channel, output_channel, 3, padding=1) | |
self.bn1 = torch.nn.BatchNorm2d(output_channel) | |
self.conv2 = torch.nn.Conv2d(output_channel, output_channel, 3, padding=1) |
This file contains hidden or 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
from __future__ import print_function, division | |
import torch | |
from torch.autograd import Variable | |
from sklearn.metrics import accuracy_score | |
from sklearn.metrics import confusion_matrix | |
import torch | |
import torch.nn as nn | |
import torch.optim as optim | |
from torch.optim import lr_scheduler |