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 tensorflow.examples.tutorials.mnist import input_data | |
mnist = input_data.read_data_sets(".", one_hot=True, reshape=False) | |
import tensorflow as tf | |
# Parameters | |
learning_rate = 0.001 | |
training_epochs = 20 | |
batch_size = 128 # Decrease batch size if you don't have enough memory | |
display_step = 1 |
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
# Quiz Solution | |
# Note: You can't run code in this tab | |
import tensorflow as tf | |
output = None | |
hidden_layer_weights = [ | |
[0.1, 0.2, 0.4], | |
[0.4, 0.6, 0.6], | |
[0.5, 0.9, 0.1], | |
[0.8, 0.2, 0.8]] |
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 numpy as np | |
from sklearn import preprocessing | |
# Example labels | |
labels = np.array([1,5,3,2,1,4,2,1,3]) | |
# Create the encoder | |
lb = preprocessing.LabelBinarizer() | |
# Here the encoder finds the classes and assigns one-hot vectors | |
lb.fit(labels) | |
# And finally, transform the labels into one-hot encoded vectors | |
lb.transform(labels) |
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 | |
output = None | |
logit_data = [2.0, 1.0, 0.1] | |
logits = tf.placeholder(tf.float32) | |
softmax = tf.nn.softmax(logits) | |
with tf.Session() as sess: | |
output = sess.run(softmax, feed_dict={logits: logit_data}) |
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 numpy as np | |
a = np.random.randn(8) | |
print(a) | |
# Rank 1 vectors | |
# (8,) | |
print(a.shape) |
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 time | |
import numpy as np | |
a = np.random.randn(1000000) | |
b = np.random.randn(1000000) | |
tic = time.time() | |
c = np.dot(a, b) | |
toc = time.time() |
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
user nginx; | |
worker_processes 1; | |
error_log /var/log/nginx/error.log warn; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include /etc/nginx/mime.types; | |
default_type application/octet-stream; |
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
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
name: istio-ingress | |
annotations: | |
kubernetes.io/ingress.class: istio | |
spec: | |
rules: | |
- http: | |
paths: |
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
def sum(values): | |
if not isinstance(values, collections.Iterable): | |
raise TypeError( parameter must be an iterable type ) | |
total = 0 | |
for v in values: | |
if not isinstance(v, (int, float)): | |
raise TypeError( elements must be numeric ) | |
total = total+ v | |
return total | |
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
def sqrt(x): | |
if not isinstance(x, (int, float)): | |
raise TypeError( x must be numeric ) | |
elif x < 0: | |
raise ValueError( x cannot be negative ) # do the real work here... |