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 sympy import * | |
import time | |
matrix = Matrix([ [ 1.0, 2.0, 1.0] , [-2.0, -3.0, 1.0] , [ 3.0, 5.0, 0.0] ]) | |
start = time.clock() | |
for x in range(0, 1000): | |
matrix.berkowitz() | |
print time.clock() - start | |
#2.103344 |
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
require 'nmatrix' | |
require 'time' | |
def timer n | |
matrix = NMatrix.new([3,3], [1.0, 2.0, 1.0, -2.0, -3.0, 1.0 ,3.0, 5.0, 0.0]) | |
now = Time.now.to_f | |
n.times do | |
matrix.charpoly | |
end | |
endd = Time.now.to_f | |
endd-now |
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
///////////////////////////////////////////////////////////////////// | |
// = NMatrix | |
// | |
// A linear algebra library for scientific computation in Ruby. | |
// NMatrix is part of SciRuby. | |
// | |
// NMatrix was originally inspired by and derived from NArray, by | |
// Masahiro Tanaka: http://narray.rubyforge.org | |
// | |
// == Copyright Information |
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 tensorflow as tf | |
import numpy as np | |
input1 = tf.placeholder(tf.int64, shape=(2, 2), name = "input1") | |
input2 = tf.placeholder(tf.int64, shape=(2, 2), name = "input2") | |
output = tf.add(input1, input2, name = "output") | |
with tf.Session() as sess: | |
tf.train.write_graph(sess.graph_def, "model/", "graph.pb", as_text=False) |
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 tensorflow as tf | |
a = tf.Graph() | |
input1 = tf.placeholder(tf.float32, shape=(2)) | |
input2 = tf.placeholder(tf.float32, shape=(2)) | |
output = tf.mul(input1, input2) | |
with tf.Session() as sess: | |
print(sess.run([output], feed_dict={input1:[7,2], input2:[2,4]})) | |
tf.train.write_graph(sess.graph_def, 'models/', 'test_graph_multi_dim.pb', as_text=True) | |
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
node { | |
name: "Placeholder" | |
op: "Placeholder" | |
attr { | |
key: "dtype" | |
value { | |
type: DT_FLOAT | |
} | |
} | |
attr { |
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 tensorflow as tf | |
from tensorflow.python.platform import gfile | |
import sys | |
def converter(filename): | |
with gfile.FastGFile(filename,'rb') as f: | |
graph_def = tf.GraphDef() | |
graph_def.ParseFromString(f.read()) | |
tf.import_graph_def(graph_def, name='') | |
tf.train.write_graph(graph_def, 'pbtxt/', 'protobuf.pbtxt', as_text=True) |
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 top five results are | |
golden retriever | |
0.7964490652084351 | |
Labrador retriever | |
0.0944252461194992 | |
kuvasz | |
0.03383997827768326 | |
clumber | |
0.005355054046958685 | |
Great Pyrenees |
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 file is useful for reading the contents of the ops generated by ruby. | |
# You can read any graph defination in pb/pbtxt format generated by ruby | |
# or by python and then convert it back and forth from human readable to binary format. | |
import tensorflow as tf | |
from google.protobuf import text_format | |
from tensorflow.python.platform import gfile | |
def pbtxt_to_graphdef(filename): | |
with open(filename, 'r') as f: |
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
3 | |
input1Placeholder* | |
dtype0 * | |
shape: | |
3 | |
input2Placeholder* | |
dtype0 * | |
shape: | |
& |
OlderNewer