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 tensorflow as tf | |
| def test1(): | |
| input1 = tf.placeholder(tf.float32, [2,3]) | |
| input2 = tf.placeholder(tf.float32, [2,3]) | |
| output = tf.add(input1, input2) | |
| with tf.Session() as sess: | |
| (sess.run([output], feed_dict={input1:[[1.0,3.0, 5.0],[2.0,4.0, 7.0]], input2:[[-5.0,1.2,4.5],[8.0,2.3, 3.1]]})) | |
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
| # chmod +x cloneConvertProto.sh | |
| printf "\033c" | |
| echo "Fetching latest protobuf from Apple" | |
| git clone https://github.com/apple/swift-protobuf.git | |
| cd swift-protobuf | |
| swift build | |
| cp .build/debug/protoc-gen-swift ./ | |
| cd .. | |
| printf "\033c" |
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
| node { | |
| name: "m1" | |
| op: "Const" | |
| attr { | |
| key: "_class" | |
| value { | |
| list { | |
| } | |
| } | |
| } |
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
| require 'tensorflow' | |
| graph = Tensorflow::Graph2.new | |
| tensor_1 = Tensorflow::Tensor.new([2,3,4,6]) | |
| tensor_2 = Tensorflow::Tensor.new([2,3,4,6]) | |
| const_1 = graph.const("m1", tensor_1) | |
| const_2 = graph.const("m2", tensor_2) | |
| opec = Tensorflow::OpSpec.new | |
| opec.name = "Additionofconstants" | |
| opec.type = "Add" | |
| opec.input = [const_1, const_2] |
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
| from __future__ import print_function | |
| import tensorflow as tf | |
| FLAGS = None | |
| a = tf.constant([[2, 3],[4,1]]) | |
| b = tf.constant([[5, 6],[1,3]]) | |
| d = tf.constant([[0, 4],[9,8]]) | |
| with tf.Session() as sess: | |
| c = sess.run(a+b) |
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
| package main | |
| import "github.com/Arafatk/glot" | |
| func main() { | |
| dimensions := 2 | |
| // The dimensions supported by the plot | |
| persist := false | |
| debug := false | |
| plot, _ := glot.NewPlot(dimensions, persist, debug) |
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
| package main | |
| import "github.com/Arafatk/glot" | |
| func main() { | |
| dimensions := 2 | |
| // The dimensions supported by the plot | |
| persist := false | |
| debug := false | |
| plot, _ := glot.NewPlot(dimensions, persist, debug) |
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
| require 'tensorflow' | |
| # Loading Saved Model | |
| saved_model = Tensorflow::Savedmodel.new | |
| saved_model.LoadSavedModel(Dir.pwd + '/break-captcha-protobuf', ['serve'], nil) | |
| # Read the image file and specify the image contents in a Tensor | |
| image_file = File.new(Dir.pwd + '/break-captcha-protobuf/captcha-1.png', "r") | |
| feeds_tensor = Tensorflow::Tensor.new(image_file.read) |
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
| # Specify the operations of tensorflow model | |
| feeds_output = saved_model.graph.operation('CAPTCHA/input_image_as_bytes') | |
| fetches = saved_model.graph.operation('CAPTCHA/prediction') | |
| # Run the Model | |
| feeds_tensor_to_output_hash = {feeds_output.output(0) => feeds_tensor} | |
| out_tensor = saved_model.session.run(feeds_tensor_to_output_hash, [fetches.output(0)], []) | |
| #Print the results | |
| puts out_tensor |
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
| # Read the image file | |
| image_file = File.new(Dir.pwd + '/break-captcha-protobuf/captcha-1.png', "r") | |
| feeds_tensor = Tensorflow::Tensor.new(image_file.read) | |