This file contains hidden or 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 collections | |
| import numpy as np | |
| import itertools | |
| SSDBoxSizes = collections.namedtuple('SSDBoxSizes', ['min', 'max']) | |
| Spec = collections.namedtuple('Spec', ['feature_map_size', 'shrinkage', 'box_sizes', 'aspect_ratios']) | |
| # the SSD orignal specs | |
| specs = [ |
This file contains hidden or 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 strip_consts(graph_def, max_const_size=32): | |
| """Strip large constant values from graph_def.""" | |
| strip_def = tf.GraphDef() | |
| for n0 in graph_def.node: | |
| n = strip_def.node.add() | |
| n.MergeFrom(n0) | |
| if n.op == 'Const': | |
| tensor = n.attr['value'].tensor | |
| size = len(tensor.tensor_content) | |
| if size > max_const_size: |
This file contains hidden or 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
| #include <iostream> | |
| #include <fstream> | |
| #include <string> | |
| #include <sstream> | |
| #include <google/protobuf/text_format.h> | |
| // for read_from_pbtxt_nocopy | |
| #include <fcntl.h> |
This file contains hidden or 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 numpy as np | |
| from caffe2.python import ( | |
| brew, | |
| model_helper, | |
| optimizer, | |
| workspace, | |
| utils, | |
| ) | |
| from caffe2.proto import caffe2_pb2 |
This file contains hidden or 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 torch | |
| from torchvision import models | |
| def parse(net, inputs = torch.randn(1, 3, 224, 224)): | |
| with torch.onnx.set_training(net, False): | |
| trace = torch.onnx.utils._trace(net, inputs) | |
| graph = trace.graph() | |
| for n in graph.nodes(): | |
| print(n.scopeName(), n.kind()) |
This file contains hidden or 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
| # Create a simple TF Graph | |
| # By Omid Alemi - Jan 2017 | |
| # Works with TF <r1.0 | |
| import tensorflow as tf | |
| I = tf.placeholder(tf.float32, shape=[None,3], name='I') # input | |
| W = tf.Variable(tf.zeros_initializer(shape=[3,2]), dtype=tf.float32, name='W') # weights | |
| b = tf.Variable(tf.zeros_initializer(shape=[2]), dtype=tf.float32, name='b') # biases | |
| O = tf.nn.relu(tf.matmul(I, W) + b, name='O') # activation / output |
OlderNewer