Skip to content

Instantly share code, notes, and snippets.

View arafatkatze's full-sized avatar
💭
Lover of life and all things beautiful

Ara arafatkatze

💭
Lover of life and all things beautiful
View GitHub Profile
# 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
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)
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)
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)
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)
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]
node {
name: "m1"
op: "Const"
attr {
key: "_class"
value {
list {
}
}
}
@arafatkatze
arafatkatze / cloneConvertTensorflow.sh
Created November 5, 2016 03:59 — forked from johndpope/cloneConvertTensorflow.sh
clone tensorflow + convert proto files to Swift /ObjC /Python /Ruby /Node/c# or c++
# 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"
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]]}))
#include <bits/stdc++.h>
using namespace std;
#define inf INFINITY
/*
const clock_t begin_time = clock();
// do something
cout << float( clock () - begin_time ) / CLOCKS_PER_SEC;
Read from a file
freopen("input.in","r",stdin);