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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:14e43d708aea630a4c8f33c6cabbbe3227646db0888b99449a3db1735adc1a9d" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:4a13ffd7eefcebc41dd8407752bb82616665a8867e1e2e6e28d10191a393b233" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:beeb4a3b3af525f231ff90355670685335a8c0d936dfde90970b9dae83b73b01" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
{ | |
"metadata": { | |
"name": "", | |
"signature": "sha256:32eee8b1ca84be1664af41531e486282214748e0d105940b99c250a717c02333" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ |
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
return tf.estimator.Estimator( | |
model_fn=model_fn, # First-class function | |
params=params, # HParams | |
config=run_config # RunConfig | |
) |
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
experiment = tf.contrib.learn.Experiment( | |
estimator=estimator, # Estimator | |
train_input_fn=train_input_fn, # First-class function | |
eval_input_fn=eval_input_fn, # First-class function | |
train_steps=params.train_steps, # Minibatch steps | |
min_eval_frequency=params.min_eval_frequency, # Eval frequency | |
train_monitors=[train_input_hook], # Hooks for training | |
eval_hooks=[eval_input_hook], # Hooks for evaluation | |
eval_steps=None # Use evaluation feeder until its empty | |
) |
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
learn_runner.run( | |
experiment_fn=experiment_fn, # First-class function | |
run_config=run_config, # RunConfig | |
schedule="train_and_evaluate", # What to run | |
hparams=params # HParams | |
) |
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
# Define the training inputs | |
def get_train_inputs(batch_size, mnist_data): | |
"""Return the input function to get the training data. | |
Args: | |
batch_size (int): Batch size of training iterator that is returned | |
by the input function. | |
mnist_data (Object): Object holding the loaded mnist data. | |
Returns: |
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 IteratorInitializerHook(tf.train.SessionRunHook): | |
"""Hook to initialise data iterator after Session is created.""" | |
def __init__(self): | |
super(IteratorInitializerHook, self).__init__() | |
self.iterator_initializer_func = None | |
def after_create_session(self, session, coord): | |
"""Initialise the iterator after the session has been created.""" | |
self.iterator_initializer_func(session) |
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
return tf.estimator.Estimator( | |
model_fn=model_fn, | |
config=config, | |
params=params, | |
) |
OlderNewer