@@ -120,12 +120,12 @@ class BaseLayer
|
||||
}
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
@@ -133,6 +133,15 @@ class BaseLayer
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */)
|
||||
{
|
||||
/* Nothing to do here */
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored delta object.
|
||||
|
||||
@@ -123,29 +123,39 @@ class BiasLayer
|
||||
}
|
||||
|
||||
//! Get the weights.
|
||||
InputDataType& Weights() const { return weights; }
|
||||
InputDataType const& Weights() const { return weights; }
|
||||
//! Modify the weights.
|
||||
InputDataType& Weights() { return weights; }
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
//! Get the gradient.
|
||||
InputDataType& Gradient() const { return gradient; }
|
||||
InputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
InputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
ar & CreateNVP(bias, "bias");
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored number of output units.
|
||||
|
||||
@@ -60,6 +60,15 @@ class BinaryClassificationLayer
|
||||
for (size_t i = 0; i < output.n_elem; i++)
|
||||
output(i) = output(i) > 0.5 ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */)
|
||||
{
|
||||
/* Nothing to do here */
|
||||
}
|
||||
}; // class BinaryClassificationLayer
|
||||
|
||||
//! Layer traits for the binary class classification layer.
|
||||
|
||||
@@ -160,29 +160,46 @@ class ConvLayer
|
||||
}
|
||||
|
||||
//! Get the weights.
|
||||
OutputDataType& Weights() const { return weights; }
|
||||
OutputDataType const& Weights() const { return weights; }
|
||||
//! Modify the weights.
|
||||
OutputDataType& Weights() { return weights; }
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
//! Get the gradient.
|
||||
OutputDataType& Gradient() const { return gradient; }
|
||||
OutputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
OutputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
ar & data::CreateNVP(wfilter, "wfilter");
|
||||
ar & data::CreateNVP(hfilter, "hfilter");
|
||||
ar & data::CreateNVP(inMaps, "inMaps");
|
||||
ar & data::CreateNVP(outMaps, "outMaps");
|
||||
ar & data::CreateNVP(xStride, "xStride");
|
||||
ar & data::CreateNVP(yStride, "yStride");
|
||||
ar & data::CreateNVP(wPad, "wPad");
|
||||
ar & data::CreateNVP(hPad, "hPad");
|
||||
}
|
||||
|
||||
private:
|
||||
/*
|
||||
|
||||
@@ -147,17 +147,17 @@ class DropoutLayer
|
||||
}
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the detla.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
@@ -180,6 +180,16 @@ class DropoutLayer
|
||||
bool Rescale() const {return rescale; }
|
||||
//! Modify the value of the rescale parameter.
|
||||
bool& Rescale() {return rescale; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(ratio, "ratio");
|
||||
ar & data::CreateNVP(rescale, "rescale");
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored delta object.
|
||||
|
||||
@@ -111,29 +111,38 @@ class LinearLayer
|
||||
}
|
||||
|
||||
//! Get the weights.
|
||||
OutputDataType& Weights() const { return weights; }
|
||||
OutputDataType const& Weights() const { return weights; }
|
||||
//! Modify the weights.
|
||||
OutputDataType& Weights() { return weights; }
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
//! Get the gradient.
|
||||
OutputDataType& Gradient() const { return gradient; }
|
||||
OutputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
OutputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
}
|
||||
|
||||
private:
|
||||
/*
|
||||
|
||||
@@ -248,27 +248,27 @@ class LSTMLayer
|
||||
}
|
||||
|
||||
//! Get the peephole weights.
|
||||
OutputDataType& Weights() const { return peepholeWeights; }
|
||||
OutputDataType const& Weights() const { return peepholeWeights; }
|
||||
//! Modify the peephole weights.
|
||||
OutputDataType& Weights() { return peepholeWeights; }
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
//! Get the peephole gradient.
|
||||
OutputDataType& Gradient() const { return peepholeGradient; }
|
||||
OutputDataType const& Gradient() const { return peepholeGradient; }
|
||||
//! Modify the peephole gradient.
|
||||
OutputDataType& Gradient() { return peepholeGradient; }
|
||||
|
||||
@@ -276,6 +276,26 @@ class LSTMLayer
|
||||
size_t SeqLen() const { return seqLen; }
|
||||
//! Modify the sequence length.
|
||||
size_t& SeqLen() { return seqLen; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(peepholes, "peepholes");
|
||||
|
||||
if (peepholes)
|
||||
{
|
||||
ar & data::CreateNVP(peepholeWeights, "peepholeWeights");
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
{
|
||||
peepholeDerivatives = arma::zeros<OutputDataType>(
|
||||
peepholeWeights.n_rows, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored number of output units.
|
||||
|
||||
@@ -64,11 +64,12 @@ class OneHotLayer
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the layer
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */)
|
||||
{
|
||||
/* Nothing to do here */
|
||||
}
|
||||
}; // class OneHotLayer
|
||||
|
||||
|
||||
@@ -133,26 +133,28 @@ class PoolingLayer
|
||||
}
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
InputDataType& OutputParameter() const { return outputParameter; }
|
||||
InputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
InputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
/**
|
||||
* Serialize the layer
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
{
|
||||
ar & data::CreateNVP(kSize, "kSize");
|
||||
ar & data::CreateNVP(pooling, "pooling");
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -100,34 +100,44 @@ class RecurrentLayer
|
||||
}
|
||||
|
||||
//! Get the weights.
|
||||
OutputDataType& Weights() const { return weights; }
|
||||
OutputDataType const& Weights() const { return weights; }
|
||||
//! Modify the weights.
|
||||
OutputDataType& Weights() { return weights; }
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& RecurrentParameter() const { return recurrentParameter; }
|
||||
InputDataType const& RecurrentParameter() const { return recurrentParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& RecurrentParameter() { return recurrentParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
OutputDataType& Delta() const { return delta; }
|
||||
OutputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
//! Get the gradient.
|
||||
OutputDataType& Gradient() const { return gradient; }
|
||||
OutputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
OutputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(recurrentParameter, "recurrentParameter");
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored number of input units.
|
||||
|
||||
@@ -69,19 +69,28 @@ class SoftmaxLayer
|
||||
}
|
||||
|
||||
//! Get the input parameter.
|
||||
InputDataType& InputParameter() const { return inputParameter; }
|
||||
InputDataType const& InputParameter() const { return inputParameter; }
|
||||
//! Modify the input parameter.
|
||||
InputDataType& InputParameter() { return inputParameter; }
|
||||
|
||||
//! Get the output parameter.
|
||||
OutputDataType& OutputParameter() const { return outputParameter; }
|
||||
OutputDataType const& OutputParameter() const { return outputParameter; }
|
||||
//! Modify the output parameter.
|
||||
OutputDataType& OutputParameter() { return outputParameter; }
|
||||
|
||||
//! Get the delta.
|
||||
InputDataType& Delta() const { return delta; }
|
||||
InputDataType const& Delta() const { return delta; }
|
||||
//! Modify the delta.
|
||||
InputDataType& Delta() { return delta; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& /* ar */, const unsigned int /* version */)
|
||||
{
|
||||
/* Nothing to do here */
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored delta object.
|
||||
|
||||
@@ -116,6 +116,16 @@ class SparseBiasLayer
|
||||
InputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
InputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
ar & data::CreateNVP(batchSize, "batchSize");
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored number of output units.
|
||||
|
||||
@@ -114,9 +114,19 @@ class SparseInputLayer
|
||||
OutputDataType& Delta() { return delta; }
|
||||
|
||||
//! Get the gradient.
|
||||
OutputDataType& Gradient() const { return gradient; }
|
||||
OutputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
OutputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
ar & data::CreateNVP(lambda, "lambda");
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored number of input units.
|
||||
|
||||
@@ -155,6 +155,18 @@ class SparseOutputLayer
|
||||
OutputDataType const& Gradient() const { return gradient; }
|
||||
//! Modify the gradient.
|
||||
OutputDataType& Gradient() { return gradient; }
|
||||
|
||||
/**
|
||||
* Serialize the layer.
|
||||
*/
|
||||
template<typename Archive>
|
||||
void Serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & data::CreateNVP(weights, "weights");
|
||||
ar & data::CreateNVP(lambda, "lambda");
|
||||
ar & data::CreateNVP(beta, "beta");
|
||||
ar & data::CreateNVP(rho, "rho");
|
||||
}
|
||||
|
||||
private:
|
||||
//! Locally-stored number of input units.
|
||||
|
||||
Reference in New Issue
Block a user