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: v1 | |
kind: Service | |
metadata: | |
labels: | |
app: chopstick-classifier | |
name: chopstick-classifier | |
spec: | |
type: LoadBalancer # we need a load balancer to distribute our requests between all replicas in the Deployment | |
ports: | |
- port: 8500 # run this |
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: apps/v1 | |
kind: Deployment | |
metadata: | |
name: chopstick-classifier | |
spec: | |
replicas: 3 # Here we tell Kubernetes to keep 3 replicas up. This will help us with reliability and scalability. The value can be changed online and Kubernetes will update the number of replicas to required quantity | |
selector: | |
matchLabels: # all pods labeled "app: chopstick-classifier will be in scope of this deployment" | |
app: chopstick-classifier | |
template: # this template will be allied to each replica in the set |
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 __future__ import absolute_import, division, print_function | |
import argparse | |
import tensorflow as tf | |
from colorama import Back, Fore, Style, init | |
from grpc.beta import implementations | |
from tensorflow_serving.apis import predict_pb2, prediction_service_pb2 |
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 __future__ import absolute_import, division, print_function | |
import argparse | |
import tensorflow as tf | |
from colorama import Back, Fore, Style, init | |
from grpc.beta import implementations | |
from tensorflow_serving.apis import classification_pb2, prediction_service_pb2 |
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
"""Train chopstick efficiency classifier and export it as Servable""" | |
import argparse | |
import numpy as np | |
import pandas as pd | |
import tensorflow as tf | |
def preprocess_data(filename, val_rows_count=20): | |
"""Load data and split it to train and validation sets""" |
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
"""Train chopstick efficiency classifier and export it as Servable""" | |
import argparse | |
import pandas as pd | |
import tensorflow as tf | |
def preprocess_data(filename, val_rows_count=20): | |
"""Load data and split it to train and validation sets""" |
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 seaborn as sns | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
fig, ax = plt.subplots(figsize=(12,8),sharey=True) | |
sns.despine(left=True) | |
sns.distplot(choice_num, ax=ax) | |
sns.distplot(fast_num, ax=ax) | |
ax.set_title("Collision count distributions") |
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 scipy.stats import ttest_rel | |
# We must do depentent t-test since all statistics were collected from the | |
# same array | |
ch_fast_test = ttest_rel(choice_num, fast_num) | |
print(f"choice sampling vs fast sampling significant: {ch_fast_test.pvalue < 0.05}, p = {ch_fast_test.pvalue}") |
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 collect_collisions(arr, sample_size, n_samples, | |
fast=False): | |
"""Collect total number of collisions made for each sample of arr. | |
Parameters | |
---------- | |
arr: np.array | |
array to sample from. | |
sample_size: int | |
sample size. |
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
%%cython | |
import numpy as np | |
cimport numpy as np | |
cimport cython # so we can use cython decorators | |
from cpython cimport bool # type annotation for boolean | |
# disable index bounds checking and negative indexing for speedups | |
@cython.wraparound(False) | |
@cython.boundscheck(False) | |
cdef cython_get_sample(np.ndarray arr, arr_len, n_iter, int sample_size, |
NewerOlder