generic_model¶
A general purpose model builder equipped with generic train, and predict functions which takes parameters for optimization strategy, minibatch, etc...

class
generic_model.
Model
(objective, placeholderdict, maxbadcount=20, momentum=None, mb=1000, verbose=True, epochs=50, learnrate=0.003, save=False, opt='grad', decay=[1, 1.0], evaluate=None, predictions=None, logdir='log/', random_seed=None, model_name='generic', clip_gradients=0.0, make_histograms=False, best_model_path='/tmp/model.ckpt', save_tensors={}, tensorboard=False, train_evaluate=None, debug=False)[source]¶ Generic model builder for training and predictions.
Parameters:  objective – Loss function
 placeholderdict – A dictionary of placeholders
 maxbadcount – For early stopping
 momentum – The momentum for tf.MomentumOptimizer
 mb – The minibatch size
 verbose – Whether to print dev error, and save_tensor evals
 epochs – maximum number of epochs to train for.
 learnrate – learnrate for gradient descent
 save – Save best model to best_model_path.
 opt – Optimization strategy. May be ‘adam’, ‘ada’, ‘grad’, ‘momentum’
 decay – Parameter for decaying learn rate.
 evaluate – Evaluation metric
 predictions – Predictions selected from feed forward pass.
 logdir – Where to put the tensorboard data.
 random_seed – Random seed for TensorFlow initializers.
 model_name – Name for model
 clip_gradients – The limit on gradient size. If 0.0 no clipping is performed.
 make_histograms – Whether or not to make histograms for model weights and activations
 best_model_path – File to save best model to during training.
 save_tensors – A hashmap of str:Tensor mappings. Tensors are evaluated during training. Evaluations of these tensors on best model are accessible via property
evaluated_tensors
.  tensorboard – Whether to make tensorboard histograms of weights and activations, and graphs of dev_error.
Returns: 
average_secs_per_epoch
¶ The average number of seconds to complete an epoch.

best_completed_epochs
¶ Number of epochs completed during at point of best dev eval during training (fractional)

best_dev_error
¶ The best dev error reached during training.

completed_epochs
¶ Number of epochs completed during training (fractional)

eval
(tensor_in, data, supplement=None)[source]¶ Evaluation of model.
Parameters: data – DataSet
to evaluate on.Returns: Result of evaluating on data for self.evaluate

evaluated_tensors
¶ A dictionary of evaluations on best model for tensors and keys specified by save_tensors argument to constructor.

placeholderdict
¶ Dictionary of model placeholders

generic_model.
get_feed_list
(batch, placeholderdict, supplement=None, train=1, debug=False)[source]¶ Parameters:  batch – A dataset object.
 placeholderdict – A dictionary where the keys match keys in batch, and the values are placeholder tensors
 supplement – A dictionary of numpy input matrices with keys corresponding to placeholders in placeholderdict, where the row size of the matrices do not correspond to the number of datapoints. For use with input data intended for embedding_lookup.
 dropouts – Dropout tensors in graph.
 dropout_flag – Whether to use Dropout probabilities for feed forward.
Returns: A feed dictionary with keys of placeholder tensors and values of numpy matrices