Skip to content

Instantly share code, notes, and snippets.

Lakshay lakshay-arora

Block or report user

Report or block lakshay-arora

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View display_results.py
# get the prediction array
predictions = predictions['predictions']
# print the actual image and the predicted result
for i, prediction in enumerate(predictions):
print("Prediction: ",np.argmax(prediction))
show(i,test_images[i])
View prediction_on_deployed_model.py
import json
import requests
# create a json string to ask query to the depoyed model
data = json.dumps({"signature_name": "serving_default",
"instances": test_images[0:3].tolist()})
# headers for the post request
headers = {"content-type": "application/json"}
View sample_image.py
# import skimage and matplotlib and random
from skimage import io
import matplotlib.pyplot as plt
%matplotlib inline
import random
# function to display image
def show(idx, title):
plt.figure()
plt.imshow(test_images[idx].reshape(28,28))
View predict-mnist-results.py
# import load_model
from tensorflow.keras.models import load_model
# give the path to model directory to load the model
loaded_model = load_model('my_model/1/')
# predict function to predict the probabilities for each class 0-9
loaded_model.predict(test_images[0:1])
# predict_classes to get the class with highest probability
View mnist-model.py
# importing the libraries
from tensorflow.keras import datasets
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
# loading dataset
(train_images, train_labels), (test_images, test_labels) = datasets.mnist.load_data()
# For training, we will use 10000 images
# And we will test our model on 1000 images
View pandas_loc11.py
# select a range of rows and columns
data.iloc[1:3,2:4]
View pandas_loc10.py
# select a range of rows
data.iloc[1:3]
View pandas_loc9.py
# select rows with particular indexes and particular columns
data.iloc[[0,2],[1,3]]
View pandas_loc8.py
# select rows with indexes
data.iloc[[0,2]]
You can’t perform that action at this time.