Skip to content

Instantly share code, notes, and snippets.

View sheikirfanbasha's full-sized avatar

Sheik Irfan Basha sheikirfanbasha

  • India
View GitHub Profile
@sheikirfanbasha
sheikirfanbasha / simple_shuffle.py
Last active August 31, 2020 17:27
Simple technique to do shuffling when the order can be random
# Simple technique to do shuffling when the order can be random
import random
import torch
# generate 1-D array with 10 elements. With numbers ranging from 0 to 20
x = torch.randn(10) * 20
x.round_() # in-place rounding. Note the "_" suffix for "round" function.
indexes = list(range(len(x))) # Get the array indices
print(indexes); # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
# set some random seed to reproduce the results correctly.
#Feel free to comment this line. Run the code and observe the output
@sheikirfanbasha
sheikirfanbasha / PreprocessImageForVGG-16.lua
Last active May 15, 2017 14:23
Pre processing the image as per VGG-16 Model requirement
vgg_mean = {103.939, 116.779, 123.68}
function check_input(img)
assert(img:dim() == 4, 'img must be N x C x H x W')
assert(img:size(2) == 3, 'img must have three channels')
end
function preprocess(img)
check_input(img)
local mean = img.new(vgg_mean):view(1, 3, 1, 1):expandAs(img)
@sheikirfanbasha
sheikirfanbasha / ImageNetClasses.json
Created February 13, 2017 09:07
Image Net Classes with respective indices
{
"0": "tench, Tinca tinca",
"1": "goldfish, Carassius auratus",
"2": "great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias",
"3": "tiger shark, Galeocerdo cuvieri",
"4": "hammerhead, hammerhead shark",
"5": "electric ray, crampfish, numbfish, torpedo",
"6": "stingray",
"7": "cock",
"8": "hen",