Skip to content

Commit

Permalink
added azure
Browse files Browse the repository at this point in the history
  • Loading branch information
axsaucedo committed Jun 6, 2019
1 parent 6e5f401 commit 471ed17
Show file tree
Hide file tree
Showing 18 changed files with 6,903 additions and 0 deletions.
4 changes: 4 additions & 0 deletions examples/models/azure_aks_deep_mnist/.s2i/environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODEL_NAME=DeepMnist
API_TYPE=REST
SERVICE_TYPE=MODEL
PERSISTENCE=0
19 changes: 19 additions & 0 deletions examples/models/azure_aks_deep_mnist/DeepMnist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import tensorflow as tf
import numpy as np

class DeepMnist(object):
def __init__(self):
self.class_names = ["class:{}".format(str(i)) for i in range(10)]
self.sess = tf.Session()
saver = tf.train.import_meta_graph("model/deep_mnist_model.meta")
saver.restore(self.sess,tf.train.latest_checkpoint("./model/"))

graph = tf.get_default_graph()
self.x = graph.get_tensor_by_name("x:0")
self.y = graph.get_tensor_by_name("y:0")

def predict(self,X,feature_names):
predictions = self.sess.run(self.y,feed_dict={self.x:X})
return predictions.astype(np.float64)


Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3,135 changes: 3,135 additions & 0 deletions examples/models/azure_aks_deep_mnist/README.md

Large diffs are not rendered by default.

3,641 changes: 3,641 additions & 0 deletions examples/models/azure_aks_deep_mnist/azure_aks_deep_mnist.ipynb

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 36 additions & 0 deletions examples/models/azure_aks_deep_mnist/create_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets("MNIST_data/", one_hot = True)
import tensorflow as tf

if __name__ == '__main__':

x = tf.placeholder(tf.float32, [None,784], name="x")

W = tf.Variable(tf.zeros([784,10]))
b = tf.Variable(tf.zeros([10]))

y = tf.nn.softmax(tf.matmul(x,W) + b, name="y")

y_ = tf.placeholder(tf.float32, [None, 10])


cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))

train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)

init = tf.initialize_all_variables()

sess = tf.Session()
sess.run(init)

for i in range(1000):
batch_xs, batch_ys = mnist.train.next_batch(100)
sess.run(train_step, feed_dict={x: batch_xs, y_: batch_ys})

correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
print(sess.run(accuracy, feed_dict = {x: mnist.test.images, y_:mnist.test.labels}))

saver = tf.train.Saver()

saver.save(sess, "model/deep_mnist_model")
53 changes: 53 additions & 0 deletions examples/models/azure_aks_deep_mnist/deep_mnist.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"apiVersion": "machinelearning.seldon.io/v1alpha2",
"kind": "SeldonDeployment",
"metadata": {
"labels": {
"app": "seldon"
},
"name": "deep-mnist"
},
"spec": {
"annotations": {
"project_name": "Tensorflow MNIST",
"deployment_version": "v1"
},
"name": "deep-mnist",
"oauth_key": "oauth-key",
"oauth_secret": "oauth-secret",
"predictors": [
{
"componentSpecs": [{
"spec": {
"containers": [
{
"image": "REPLACE_FOR_IMAGE_AND_TAG",
"imagePullPolicy": "IfNotPresent",
"name": "classifier",
"resources": {
"requests": {
"memory": "1Mi"
}
}
}
],
"terminationGracePeriodSeconds": 20
}
}],
"graph": {
"children": [],
"name": "classifier",
"endpoint": {
"type" : "REST"
},
"type": "MODEL"
},
"name": "single-model",
"replicas": 1,
"annotations": {
"predictor_version" : "v1"
}
}
]
}
}
2 changes: 2 additions & 0 deletions examples/models/azure_aks_deep_mnist/model/checkpoint
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
model_checkpoint_path: "deep_mnist_model"
all_model_checkpoint_paths: "deep_mnist_model"
Binary file not shown.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions examples/models/azure_aks_deep_mnist/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow>=1.12.0
12 changes: 12 additions & 0 deletions examples/models/azure_aks_deep_mnist/tiller-role-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tiller-role-binding
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: tiller
namespace: kube-system

0 comments on commit 471ed17

Please sign in to comment.