|
ConvNet
1.0
A GPU-based C++ implementation of Convolutional Neural Nets
|
A Convolutional Net Model. More...
#include <convnet.h>
Public Member Functions | |
| ConvNet (const string &model_file) | |
| Instantiate a model using the config in model_file. | |
| void | SetupDataset (const string &train_data_config_file) |
| virtual void | SetupDataset (const string &train_data_config_file, const string &val_data_config_file) |
| virtual void | Train () |
| Start training. More... | |
| void | Validate (DataHandler *dataset, vector< float > &error) |
| Validate the model on the specfied dataset and return the error. More... | |
| void | Validate (vector< float > &error) |
| Validate the model on the validation dataset and return the error. More... | |
| void | Save () |
| Write the model to disk. More... | |
| void | Save (const string &output_file) |
| Write the model to disk in the file specified. More... | |
| void | Load () |
| Load the model. More... | |
| void | Load (const string &input_file) |
| Load the model from the file specified. More... | |
| void | Display () |
| Display the state of the model. More... | |
| void | DumpOutputs (const string &output_file, DataHandler *dataset, const vector< string > &layer_names) |
| Write the state of the layers to disk. More... | |
| void | DumpOutputs (const string &output_file, const vector< string > &layer_names) |
| Write the state of the layers to disk. More... | |
| void | AllocateMemory (bool fprop_only) |
| Allocate memory for the model. More... | |
Protected Member Functions | |
| void | BuildNet () |
| Creates layers and edges. More... | |
| void | DestroyNet () |
| Release all memory held by the model. More... | |
| void | AllocateLayerMemory () |
| Allocate layer memory for using mini-batches of batch_size_. More... | |
| void | AllocateEdgeMemory (bool fprop_only) |
| Allocate memory for edges. More... | |
| string | GetCheckpointFilename () |
| void | TimestampModel () |
| void | Sort () |
| Topologically sort layers. More... | |
| void | Fprop (Layer &input, Layer &output, Edge &edge, bool overwrite) |
| Forward propagate one layer. More... | |
| virtual void | Bprop (Layer &output, Layer &input, Edge &edge, bool overwrite, bool update_weights) |
| Back propagate through one layer. More... | |
| virtual void | Fprop (bool train) |
| Forward propagate through the network. More... | |
| virtual void | Bprop (bool update_weights) |
| Backpropagate through the network and update weights. More... | |
| virtual void | ComputeDeriv () |
| Computes the derivative of the loss function. More... | |
| virtual void | GetLoss (vector< float > &error) |
| Computes the loss function (to be displayed). More... | |
| void | DumpOutputs (const string &output_file, DataHandler *dataset, vector< Layer * > &layers) |
| Write the state of the layers to disk. More... | |
| virtual void | TrainOneBatch (vector< float > &error) |
| Takes one optimization step. More... | |
| void | DisplayLayers () |
| void | DisplayEdges () |
| void | InsertPolyak () |
| void | LoadPolyakWeights () |
| void | LoadCurrentWeights () |
| void | WriteLog (int current_iter, float time, float training_error) |
| void | WriteLog (int current_iter, float time, const vector< float > &training_error) |
| void | WriteValLog (int current_iter, const vector< float > &error) |
| Layer * | GetLayerByName (const string &name) |
| bool | CheckReduceLearningRate (const vector< float > &val_error) |
| Decides if learning rate should be reduced. More... | |
| void | ReduceLearningRate (const float factor) |
| Multiply learning rate by factor. More... | |
Static Protected Member Functions | |
| static void | AddVectors (vector< float > &a, vector< float > &b) |
Protected Attributes | |
| config::Model | model_ |
| vector< Layer * > | layers_ |
| The model protobuf config. More... | |
| vector< Layer * > | data_layers_ |
| The layers in the network. More... | |
| vector< Layer * > | input_layers_ |
| Layers which have data associated with them. More... | |
| vector< Layer * > | output_layers_ |
| Input layers. More... | |
| vector< Edge * > | edges_ |
| Output layers. More... | |
| int | max_iter_ |
| The edges in the network. More... | |
| int | batch_size_ |
| int | current_iter_ |
| int | lr_reduce_counter_ |
| DataHandler * | train_dataset_ |
| DataHandler * | val_dataset_ |
| string | checkpoint_dir_ |
| string | output_file_ |
| string | model_name_ |
| ImageDisplayer | displayer_ |
| string | model_filename_ |
| string | timestamp_ |
| string | log_file_ |
| string | val_log_file_ |
A Convolutional Net Model.
This class provides the interface for training and using conv nets.
|
protected |
Allocate memory for edges.
| fprop_only | If true, does not allocate memory needed for optimization. |
|
protected |
Allocate layer memory for using mini-batches of batch_size_.
| void ConvNet::AllocateMemory | ( | bool | fprop_only | ) |
Allocate memory for the model.
| fprop_only | If true, does not allocate memory needed for optimization. |
|
protectedvirtual |
Back propagate through one layer.
Passes down the gradients from the output layer to the input layer. Also updates the weights on the edge (if update_weights is true).
| output | the output layer (gradients w.r.t this have been computed). |
| input | the input layer (gradients w.r.t this will be computed here). |
| edge | the edge connecting the input to the output. |
| overwrite | If true, overwrite the deriv present in input, else add to it. |
| update_weights | If true, the weights will be updated. |
|
protectedvirtual |
Backpropagate through the network and update weights.
Reimplemented in MultiGPUConvNet.
|
protected |
Creates layers and edges.
|
protected |
Decides if learning rate should be reduced.
|
protectedvirtual |
Computes the derivative of the loss function.
|
protected |
Release all memory held by the model.
| void ConvNet::Display | ( | ) |
Display the state of the model.
Shows the layers and edges for which display is enabled.
| void ConvNet::DumpOutputs | ( | const string & | output_file, |
| DataHandler * | dataset, | ||
| const vector< string > & | layer_names | ||
| ) |
Write the state of the layers to disk.
This method runs the model on the specified dataset and writes the layer states out to disk in a hdf5 file.
| output_file | The name of the output hdf5 file. |
| dataset | The dataset to be run. |
| layer_names | The names of the layers whose state needs to be written out. |
| void ConvNet::DumpOutputs | ( | const string & | output_file, |
| const vector< string > & | layer_names | ||
| ) |
Write the state of the layers to disk.
This method runs the model on the train dataset and writes the layer states out to disk in a hdf5 file.
| output_file | The name of the output hdf5 file. |
| layer_names | The names of the layers whose state needs to be written out. |
|
protected |
Write the state of the layers to disk.
This method runs the model on the specified dataset and writes the layer states out to disk in a hdf5 file.
| output_file | The name of the output hdf5 file. |
| dataset | The dataset to be run. |
| layers | The layers whose state needs to be written out. |
Forward propagate one layer.
Passes up input through the edge and updates the state of the output.
| input | the input layer. |
| output | the output layer. |
| edge | the edge connecting the input to the output. |
| overwrite | If true, overwrite the state present in output, else add to it. |
|
protectedvirtual |
Forward propagate through the network.
| train | If true, this forward prop is being done during training, otherwise during test/validation. Used for determining whether to use drop units stochastcially or use all of them. |
Reimplemented in MultiGPUConvNet.
|
protectedvirtual |
Computes the loss function (to be displayed).
Reimplemented in GradChecker.
| void ConvNet::Load | ( | ) |
Load the model.
| void ConvNet::Load | ( | const string & | input_file | ) |
Load the model from the file specified.
|
protected |
Multiply learning rate by factor.
| void ConvNet::Save | ( | ) |
Write the model to disk.
| void ConvNet::Save | ( | const string & | output_file | ) |
Write the model to disk in the file specified.
|
protected |
Topologically sort layers.
|
virtual |
Start training.
|
protectedvirtual |
Takes one optimization step.
| void ConvNet::Validate | ( | DataHandler * | dataset, |
| vector< float > & | error | ||
| ) |
Validate the model on the specfied dataset and return the error.
| dataset | The dataset. |
| error | A vector of errors (one element for each output layer). |
| void ConvNet::Validate | ( | vector< float > & | error | ) |
Validate the model on the validation dataset and return the error.
| error | A vector of errors (one element for each output layer). |
|
protected |
The layers in the network.
|
protected |
Output layers.
|
protected |
Layers which have data associated with them.
|
protected |
The model protobuf config.
|
protected |
The edges in the network.
|
protected |
Input layers.
1.8.7