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
name: "spacenet_SSD_300x300_train" | |
layer { | |
name: "data" | |
type: "AnnotatedData" | |
top: "data" | |
top: "label" | |
include { | |
phase: TRAIN | |
} | |
transform_param { |
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
"" | |
This script does a quick-and-dirty validation of the ImageNet dataset. | |
TODO - a quick EDA (exploratory data analysis), which is customary before any analysis | |
""" | |
import os | |
import glob | |
import imghdr | |
import argparse | |
nb_classes = 1000 |
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 json | |
from pudb import set_trace | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
with open('good_run_raport.json') as json_file: | |
data = json.load(json_file) | |
print("top 5") |
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 MyLinearLayer(nn.Module): | |
""" Custom Linear layer but mimics a standard linear layer """ | |
def __init__(self, size_in, size_out): | |
super().__init__() | |
self.size_in, self.size_out = size_in, size_out | |
weights = torch.Tensor(size_out, size_in) | |
self.weights = nn.Parameter(weights) # nn.Parameter is a Tensor that's a module parameter. | |
bias = torch.Tensor(size_out) | |
self.bias = nn.Parameter(bias) |
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 BasicModel(nn.Module): | |
def __init__(self): | |
super().__init__() | |
self.conv = nn.Conv2d(1, 128, 3) | |
# self.linear = nn.Linear(256, 2) | |
self.linear = MyLinearLayer(256, 2) | |
def forward(self, x): | |
x = self. conv(x) | |
x = x.view(-1, 256) |
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
torch.manual_seed(0) # for repeatable results | |
basic_model = BasicModel() | |
inp = np.array([[[[1,2,3,4], # batch(=1) x channels(=1) x height x width | |
[1,2,3,4], | |
[1,2,3,4]]]]) | |
x = torch.tensor(inp, dtype=torch.float) | |
print('Forward computation thru model:', basic_model(x)) |
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
""" Demonstrates the easy of integration of a custom layer """ | |
import math | |
import torch | |
import torch.nn as nn | |
import numpy as np |
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
""" | |
The simple three-layer fully-connected network | |
converted to onnx; 90% accuracy on MNIST | |
""" | |
import tensorflow as tf | |
import tf2onnx | |
from tf2onnx import loader | |
import math | |
# The MNIST dataset has 10 classes, representing the digits 0 through 9. |
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
""" | |
A simple example how to call tensorflow-onnx via python. | |
""" | |
import tensorflow as tf | |
import tf2onnx | |
from tf2onnx import loader | |
import numpy as np | |
with tf.compat.v1.Session() as sess: |
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
# from https://janakiev.com/blog/python-shell-commands/ | |
# Must use python2.7 | |
import os, stat | |
import subprocess | |
import math | |
import argparse | |
def nth_root(num,root): | |
return num ** (1/root) |
OlderNewer