Skip to content

Instantly share code, notes, and snippets.

View ayooshkathuria's full-sized avatar

Ayoosh Kathuria ayooshkathuria

  • Phaidra
  • Delhi
View GitHub Profile
@ayooshkathuria
ayooshkathuria / op_vs_vm_costs.py
Last active April 20, 2021 19:38
Compare costs of on-remise machines vs clouds for Deep Learning
import matplotlib.pyplot as plt
import pandas as pd
import plotly.express as px
pd.options.plotting.backend = "plotly"
UTILIZATION = 0.1
OP_UPFRONT_COST = 3300
ELECTRICTY_COST_KWH = 0.13
import numpy as np
import matplotlib.pyplot as plt
import random
import time
# Size of dataset to be generated. The final size is 4 * data_size
data_size = 1000
num_iters = 50
num_clusters = 4
import numpy as np
import matplotlib.pyplot as plt
import random
import time
# Size of dataset to be generated. The final size is 4 * data_size
data_size = 1000
num_iters = 50
num_clusters = 4
import numpy as np
import matplotlib.pyplot as plt
import random
import time
# Size of dataset to be generated. The final size is 4 * data_size
data_size = 1000
num_iters = 50
num_clusters = 4
@ayooshkathuria
ayooshkathuria / partition_data.py
Last active January 18, 2020 07:27
Partition CamVid Data for GauGAN
import os
from shutil import copy
import random
from tqdm import tqdm
partition_percentage = 90
annotations_dir = 'GauGAN_Annotations'
annotations_files = os.listdir(annotations_dir)
annotations_files = [os.path.join(os.path.realpath("."), annotations_dir, x) for x in annotations_files]
@ayooshkathuria
ayooshkathuria / convert_annotations.py
Last active January 18, 2020 07:28
Convert CamVid RGB segmentation maps to ones with class indices
import numpy as np
import os
import cv2
from copy import deepcopy
from matplotlib import pyplot as plt
from tqdm import tqdm
from shutil import copy
with open("label_colors.txt", "r") as file:
label_colors = file.read().split("\n")[:-1]
@ayooshkathuria
ayooshkathuria / convert_annotations.py
Created January 6, 2020 12:21
Convert CamVid RGB segmentation maps to ones with class indices
import numpy as np
import os
import cv2
from copy import deepcopy
from matplotlib import pyplot as plt
from tqdm import tqdm
from shutil import copy
with open("label_colors.txt", "r") as file:
label_colors = file.read().split("\n")[:-1]
Gradient of L w.r.t to w1: -36.0
Gradient of L w.r.t to w2: -28.0
Gradient of L w.r.t to w3: -8.0
Gradient of L w.r.t to w4: -20.0
from torch import FloatTensor
from torch.autograd import Variable
# Define the leaf nodes
a = Variable(FloatTensor([4]))
weights = [Variable(FloatTensor([i]), requires_grad=True) for i in (2, 5, 9, 7)]
# unpack the weights for nicer assignment
@ayooshkathuria
ayooshkathuria / pytorch_building_blocks.py
Created December 3, 2017 16:49
Basic Building Blocks of PyTorch
import torch
x = torch.Tensor(5, 4)
print(x)