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
# 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 |
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
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) |
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
{ | |
"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", |