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 division | |
import urlparse | |
import os | |
import numpy | |
import boto3 | |
import tensorflow | |
from tensorflow.python.keras._impl import keras | |
from tensorflow.python.estimator.export.export_output import PredictOutput |
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 division | |
import os | |
import numpy | |
import tensorflow as tf | |
from tensorflow.python.estimator.export.export_output import PredictOutput | |
from tensorflow.python.estimator.export.export import build_raw_serving_input_receiver_fn | |
from tensorflow.python.saved_model import signature_constants | |
from tensorflow.python import debug as tf_debug |
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 os | |
import psutil | |
import numpy | |
import tensorflow | |
from tensorflow.python.keras._impl import keras | |
from tensorflow.python.keras._impl.keras.backend import _GRAPH_LEARNING_PHASES | |
print("Tensorflow version: {0}".format(tensorflow.VERSION)) |
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
# just the fn from model_store that takes: | |
model_builder = model_class(model_artifacts, **model_parameters) | |
model_builder.build_model(inp_placeholder) | |
# dict of tensors like {'softmax':softmax_layer, 'oov_code':oov_code} | |
tensors = model_builder.give_outputs() | |
if mode == tensorflow.estimator.ModeKeys.PREDICT: | |
return tensorflow.estimator.EstimatorSpec( | |
mode=mode, | |
predictions=tensors, |
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 | |
import tensorflow | |
print("Tensorflow version: {0}".format(tensorflow.VERSION)) | |
DATA_SIZE = 1024 | |
BATCH_SIZE = 32 | |
N_EPOCHS = 1 | |
EMBED_DIM = 100 |
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 glob | |
import os | |
import shutil | |
import numpy | |
import tensorflow | |
import pandas as pd | |
from tensorflow.python.estimator.export.export_output import PredictOutput | |
from tensorflow.python.saved_model import signature_constants | |
from protobuf_to_dict import protobuf_to_dict |
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 os | |
import json | |
import numpy | |
import tensorflow | |
from tensorflow.python.estimator.export.export import build_raw_serving_input_receiver_fn | |
print("Tensorflow version: {0}".format(tensorflow.VERSION)) | |
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' |
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
class TokenizeLookupLayer(keras.layers.Layer): | |
""" | |
Layer that encapsulates the following: | |
- Tokenizing sentences by space (or given delimiter) | |
- Looking up the words with a given vocabulary list / table | |
- Resetting the shape of the above to be batch_size x pad_len (using dark magic) | |
# Input Shape | |
2D string tensor with shape `(batch_size, 1)` | |
# Output Shape | |
2D int32 tensor with shape `(batch_size, pad_len)` |
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 division | |
import os | |
import numpy | |
import tensorflow | |
from tensorflow.python.keras._impl import keras | |
from tensorflow.python.estimator.export.export_output import PredictOutput | |
from tensorflow.python.estimator.export.export import build_raw_serving_input_receiver_fn | |
from tensorflow.python.saved_model import signature_constants |
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 itertools | |
import numpy | |
import tensorflow | |
class TokenizeLookupLayer(tensorflow.keras.layers.Layer): | |
""" | |
Layer that encapsulates the following: | |
- Tokenizing sentences by space (or given delimiter) | |
- Looking up the words with a given vocabulary list / table |