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 cv2 | |
from scipy.spatial import distance as dist | |
import numpy as np | |
def resize(image, width=None, height=None, inter=cv2.INTER_AREA): | |
dim = None | |
(h, w) = image.shape[:2] | |
# check to see if the width is None | |
if width is None: |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
## DIVIDE -> mergesort | |
## CONQUER -> mergesort | |
## COMBINE -> merge | |
def merge(S1, S2, S): | |
''' | |
S1-> First sorted seq | |
S2-> Second sorted seq | |
S -> Original seq | |
''' |
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
def quicksort(S): | |
if len(S)<2: | |
print("[RETURNED]length of list less than 2") | |
return | |
pivot = S[-1] | |
print("[INFO] pivot: ", pivot) | |
L = [] | |
G = [] |
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
class LinkedStack: | |
def __init__(self): | |
self._head = None | |
self._size = 0 | |
class _node: | |
__slots__ = '_element', '_nextP' | |
def __init__(self, element, nextP): | |
self._element = element |
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
net = Net().to(device) | |
optimizer = optim.Adam(net.parameters()) | |
wandb.init(project='pytorchw_b') | |
wandb.watch(net, log='all') | |
for epoch in range(10): | |
train(net, device, trainloader, optimizer, epoch) | |
test(net, device, testloader, classes) | |
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
if logwandb: | |
wandb.log({'lr': lr_schedule.get_lr()[0], 'loss': loss}) |
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
lr_finder = LRFinder(net, optimizer, device) | |
lr_finder.range_test(trainloader, end_lr=10, num_iter=100, logwandb=True) |
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
class NetforExplode(nn.Module): | |
def __init__(self): | |
super(NetforExplode, self).__init__() | |
self.conv1 = nn.Conv2d(1, 32, 3, 1) | |
self.conv1.weight.data.fill_(100) | |
self.conv1.bias.data.fill_(-100) | |
self.conv2 = nn.Conv2d(32, 64, 3, 1) | |
self.conv2.weight.data.fill_(100) |
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
class Net(nn.Module): | |
def __init__(self): | |
super(Net, self).__init__() | |
self.conv1 = nn.Conv2d(3, 32, 3, 1) | |
torch.nn.init.kaiming_uniform_(self.conv1.weight, mode='fan_in', nonlinearity='relu') | |
self.conv2 = nn.Conv2d(32, 32, 3, 1) | |
torch.nn.init.kaiming_uniform_(self.conv2.weight, mode='fan_in', nonlinearity='relu') |
OlderNewer