pydbm.cnn package

Submodules

pydbm.cnn.convolutional_neural_network module

class pydbm.cnn.convolutional_neural_network.ConvolutionalNeuralNetwork

Bases: object

Convolutional Neural Network.

back_propagation

Back propagation in CNN.

Parameters:Delta.
Returns.
Delta.
computable_loss

getter

forward_propagation

Forward propagation in CNN.

Parameters:img_arrnp.ndarray of image file array.
Returns:Propagated np.ndarray.
get_computable_loss

getter

get_layerable_cnn_list

getter

get_opt_params

getter

get_verificatable_result

getter

get_weight_decay_term

getter

inference

Inference the feature points to reconstruct the time-series.

Override.

Parameters:observed_arr – Array like or sparse matrix as the observed data points.
Returns:Predicted array like or sparse matrix.
layerable_cnn_list

getter

learn

Learn.

Parameters:
  • observed_arrnp.ndarray of observed data points.
  • target_arrnp.ndarray of labeled data. If None, the function of this cnn model is equivalent to Convolutional Auto-Encoder.
learn_generated

Learn features generated by FeatureGenerator.

Parameters:feature_generator – is-a FeatureGenerator.
opt_params

getter

optimize

Back propagation.

Parameters:
  • learning_rate – Learning rate.
  • epoch – Now epoch.
output_back_propagate

Back propagation in output layer.

Parameters:
  • pred_arrnp.ndarray of predicted data points.
  • delta_output_arr – Delta.
Returns:

Tuple data. - np.ndarray of Delta, - list of gradations.

output_forward_propagate

Forward propagation in output layer.

Parameters:pred_arrnp.ndarray of predicted data points.
Returns:np.ndarray of propagated data points.
save_pre_learned_params

Save pre-learned parameters.

Parameters:
  • dir_path – Path of dir. If None, the file is saved in the current directory.
  • file_name – The naming rule of files. If None, this value is cnn.
set_computable_loss

setter

set_layerable_cnn_list

setter

set_opt_params

setter

set_verificatable_result

setter

set_weight_decay_term

setter

setup_output_layer

Setup output layer.

Parameters:
  • cnn_output_graph – Computation graph which is-a CNNOutputGraph to compute parameters in output layer.
  • pre_learned_path – File path that stores pre-learned parameters.
verificatable_result

getter

weight_decay_term

getter

pydbm.cnn.feature_generator module

class pydbm.cnn.feature_generator.FeatureGenerator

Bases: object

Feature generator.

batch_size

Batch size of Mini-batch.

epochs

Epochs of Mini-batch.

generate

Generate feature points.

Returns:The tuple of feature points. The shape is: (Training data, Training label, Test data, Test label).

pydbm.cnn.layerable_cnn module

class pydbm.cnn.layerable_cnn.LayerableCNN

Bases: object

The abstract class of convolutional neural network.

affine_to_img

Affine transform for Convolution.

Parameters:
  • reshaped_img_arrnp.ndarray of 2-rank image array.
  • img_arrnp.ndarray of 4-rank image array.
  • kernel_height – Height of kernel.
  • kernel_width – Width of kernel.
  • stride – Stride.
  • pad – padding value.
Returns:

2-rank image array.

affine_to_matrix

Affine transform for Convolution.

Parameters:
  • img_arrnp.ndarray of 4-rank image array.
  • kernel_height – Height of kernel.
  • kernel_width – Width of kernel.
  • stride – Stride.
  • pad – padding value.
Returns:

2-rank image array.

back_propagate

Back propagation in CNN layers.

Parameters:delta_arr – 4-rank array like or sparse matrix.
Returns:3-rank array like or sparse matrix.
delta_bias_arr

Delta of bias vector.

delta_weight_arr

Delta of weight matirx.

forward_propagate

Forward propagation in CNN layers.

Parameters:matriimg_arr – 4-rank array like or sparse matrix.
Returns:4-rank array like or sparse matrix.
graph

Graph which is-a Synapse.

reset_delta

Reset delta.

pydbm.cnn.spatio_temporal_auto_encoder module

class pydbm.cnn.spatio_temporal_auto_encoder.SpatioTemporalAutoEncoder

Bases: object

Spatio-Temporal Auto-Encoder.

The Spatio-Temporal Auto-Encoder can learn the regular patterns in the training videos(Baccouche, M., et al., 2012, Patraucean, V., et al. 2015).

This model consists of spatial Auto-Encoder and temporal Encoder/Decoder. The spatial Auto-Encoder is a Convolutional Auto-Encoder for learning spatial structures of each video frame. The temporal Encoder/Decoder is an Encoder/Decoder based on LSTM scheme for learning temporal patterns of the encoded spatial structures. The spatial encoder and decoder have two convolutional and deconvolutional layers respectively, while the temporal encoder and decoder are to act as a twin LSTM models.

References

  • https://github.com/chimera0/accel-brain-code/blob/master/Deep-Learning-by-means-of-Design-Pattern/demo/demo_stacked_auto_encoder.ipynb
  • Baccouche, M., Mamalet, F., Wolf, C., Garcia, C., & Baskurt, A. (2012, September). Spatio-Temporal Convolutional Sparse Auto-Encoder for Sequence Classification. In BMVC (pp. 1-12).
  • Chong, Y. S., & Tay, Y. H. (2017, June). Abnormal event detection in videos using spatiotemporal autoencoder. In International Symposium on Neural Networks (pp. 189-196). Springer, Cham.
  • Masci, J., Meier, U., Cireşan, D., & Schmidhuber, J. (2011, June). Stacked convolutional auto-encoders for hierarchical feature extraction. In International Conference on Artificial Neural Networks (pp. 52-59). Springer, Berlin, Heidelberg.
  • Patraucean, V., Handa, A., & Cipolla, R. (2015). Spatio-temporal video autoencoder with differentiable memory. arXiv preprint arXiv:1511.06309.
back_propagation

Back propagation in CNN.

Parameters:Delta.
Returns.
Delta.
extract_features_points

Extract features points.

Returns:Tuple data. - Temporal encoded feature points, - Temporal decoded feature points, - Fully-connected Spatio encoded feature points and Temporal decoded feature points
forward_propagation

Forward propagation in Convolutional Auto-Encoder.

Override.

Parameters:img_arrnp.ndarray of image file array.
Returns:Propagated np.ndarray.
get_layerable_cnn_list

getter

get_verificatable_result

getter

inference

Inference the feature points to reconstruct the time-series.

Override.

Parameters:observed_arr – Array like or sparse matrix as the observed data points.
Returns:Predicted array like or sparse matrix.
layerable_cnn_list

getter

learn

Learn.

Parameters:
  • observed_arrnp.ndarray of observed data points.
  • target_arrnp.ndarray of labeled data. If None, the function of this cnn model is equivalent to Convolutional Auto-Encoder.
learn_generated

Learn features generated by FeatureGenerator.

Parameters:feature_generator – is-a FeatureGenerator.
load_pre_learned_params

Load pre-learned parameters.

Parameters:dir_path – Path of dir. If None, the file is saved in the current directory.
optimize

Back propagation.

Parameters:
  • learning_rate – Learning rate.
  • epoch – Now epoch.
save_pre_learned_params

Save pre-learned parameters.

Parameters:dir_path – Path of dir. If None, the file is saved in the current directory.
set_layerable_cnn_list

setter

set_verificatable_result

setter

temporal_back_propagation

Back propagation in temporal Encoder/Decoder.

Parameters:
  • pred_arrnp.ndarray of predicted data points from decoder.
  • delta_output_arr – Delta.
Returns:

Tuple data. - decoder’s list of gradations, - encoder’s np.ndarray of Delta, - encoder’s list of gradations.

temporal_inference

Inference the feature points to reconstruct the time-series.

Override.

Parameters:
  • observed_arr – Array like or sparse matrix as the observed data ponts.
  • hidden_activity_arr – Array like or sparse matrix as the state in hidden layer.
  • rnn_activity_arr – Array like or sparse matrix as the state in RNN.
Returns:

Tuple data. - Array like or sparse matrix of reconstructed instances of time-series, - Array like or sparse matrix of the state in hidden layer, - Array like or sparse matrix of the state in RNN.

temporal_optimize

Back propagation in temporal Encoder/Decoder.

Parameters:
  • decoder_grads_list – decoder’s list of graduations.
  • encoder_grads_list – encoder’s list of graduations.
  • learning_rate – Learning rate.
  • epoch – Now epoch.
verificatable_result

getter

Module contents