-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
6,903 additions
and
0 deletions.
There are no files selected for viewing
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
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 |
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
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 added
BIN
+1.57 MB
examples/models/azure_aks_deep_mnist/MNIST_data/t10k-images-idx3-ubyte.gz
Binary file not shown.
Binary file added
BIN
+4.44 KB
examples/models/azure_aks_deep_mnist/MNIST_data/t10k-labels-idx1-ubyte.gz
Binary file not shown.
Binary file added
BIN
+9.45 MB
examples/models/azure_aks_deep_mnist/MNIST_data/train-images-idx3-ubyte.gz
Binary file not shown.
Binary file added
BIN
+28.2 KB
examples/models/azure_aks_deep_mnist/MNIST_data/train-labels-idx1-ubyte.gz
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
3,641 changes: 3,641 additions & 0 deletions
3,641
examples/models/azure_aks_deep_mnist/azure_aks_deep_mnist.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+3.41 KB
...s/azure_aks_deep_mnist/azure_aks_deep_mnist_files/azure_aks_deep_mnist_11_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.41 KB
...s/azure_aks_deep_mnist/azure_aks_deep_mnist_files/azure_aks_deep_mnist_58_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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") |
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
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" | ||
} | ||
} | ||
] | ||
} | ||
} |
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
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 added
BIN
+30.7 KB
examples/models/azure_aks_deep_mnist/model/deep_mnist_model.data-00000-of-00001
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tensorflow>=1.12.0 |
12 changes: 12 additions & 0 deletions
12
examples/models/azure_aks_deep_mnist/tiller-role-binding.yaml
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
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 |