ab.util¶
Package helper utilities.
-
aboleth.util.
batch
(feed_dict, batch_size, n_iter=10000, N_=None)¶ Create random batches for Stochastic gradients.
Feed dict data generator for SGD that will yeild random batches for a a defined number of iterations, which can be infinite. This generator makes consecutive passes through the data, drawing without replacement on each pass.
Parameters: - feed_dict (dict of ndarrays) – The data with
{tf.placeholder: data}
entries. This assumes all items have the same length! - batch_size (int) – number of data points in each batch.
- n_iter (int, optional) – The number of iterations
- N (tf.placeholder (int), optional) – Place holder for the size of the dataset. This will be fed to an algorithm.
Yields: dict – with each element an array length
batch_size
, i.e. a subset of data, and an element forN_
. Use this as your feed-dict when evaluating a loss, training, etc.- feed_dict (dict of ndarrays) – The data with
-
aboleth.util.
batch_prediction
(feed_dict, batch_size)¶ Split the data in a feed_dict into contiguous batches for prediction.
Parameters: - feed_dict (dict of ndarrays) – The data with
{tf.placeholder: data}
entries. This assumes all items have the same length! - batch_size (int) – number of data points in each batch.
Yields: - ndarray – an array of shape approximately (
batch_size
,) of indices into the original data for the current batch - dict – with each element an array length
batch_size
, i.e. a subset of data. Use this as your feed-dict when evaluating a model, prediction, etc.
Note
The exact size of the batch may not be
batch_size
, but the nearest size that splits the size of the data most evenly.- feed_dict (dict of ndarrays) – The data with
-
aboleth.util.
pos_variable
(initial_value, name=None, **kwargs)¶ Make a tf.Variable that will remain positive.
Parameters: - initial_value (float, np.array, tf.Tensor) – the initial value of the Variable.
- name (string) – the name to give the returned tensor.
- kwargs (dict) – optional arguments to give the created
tf.Variable
.
Returns: var – a tf.Variable within a Tensor that will remain positive through training.
Return type: tf.Tensor
-
aboleth.util.
summary_histogram
(values)¶ Add a summary histogram to TensorBoard.
This will add a summary histogram with name
variable.name
.Parameters: values (tf.Variable, tf.Tensor) – the Tensor to add to the summaries.
-
aboleth.util.
summary_scalar
(values)¶ Add a summary scalar to TensorBoard.
This will add a summary scalar with name
variable.name
.Parameters: values (tf.Variable, tf.Tensor) – the Tensor to add to the summaries.