Commit 4c1a32f7 authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

BUG: wrong dimension detected when reading AE model

No related merge requests found
Showing with 7 additions and 4 deletions
+7 -4
...@@ -179,6 +179,7 @@ AutoencoderModel<TInputValue,NeuronType> ...@@ -179,6 +179,7 @@ AutoencoderModel<TInputValue,NeuronType>
shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning); shark::MaxIterations<> criterion(m_NumberOfIterationsFineTuning);
TrainNetwork(criterion, inputSamples_copy, ofs); TrainNetwork(criterion, inputSamples_copy, ofs);
} }
this->SetDimension(m_NumberOfHiddenNeurons[m_NumberOfHiddenNeurons.Size()-1]);
} }
template <class TInputValue, class NeuronType> template <class TInputValue, class NeuronType>
...@@ -387,8 +388,8 @@ AutoencoderModel<TInputValue,NeuronType> ...@@ -387,8 +388,8 @@ AutoencoderModel<TInputValue,NeuronType>
// This gives us the dimension if we keep the encoder and decoder // This gives us the dimension if we keep the encoder and decoder
size_t feature_layer_index = m_Net.layerMatrices().size()/2; size_t feature_layer_index = m_Net.layerMatrices().size()/2;
// number of neurons in the feature layer (first dimension of the first decoder weight matrix) // number of neurons in the feature layer (second dimension of the first decoder weight matrix)
this->m_Dimension = m_Net.layerMatrix(feature_layer_index).size1(); this->SetDimension(m_Net.layerMatrix(feature_layer_index).size2());
} }
template <class TInputValue, class NeuronType> template <class TInputValue, class NeuronType>
...@@ -407,7 +408,8 @@ AutoencoderModel<TInputValue,NeuronType> ...@@ -407,7 +408,8 @@ AutoencoderModel<TInputValue,NeuronType>
shark::Data<shark::RealVector> data = shark::createDataFromRange(features); shark::Data<shark::RealVector> data = shark::createDataFromRange(features);
data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part // features layer for a network containing the encoder and decoder part
data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data);
TargetSampleType target; TargetSampleType target;
target.SetSize(this->m_Dimension); target.SetSize(this->m_Dimension);
...@@ -432,7 +434,8 @@ AutoencoderModel<TInputValue,NeuronType> ...@@ -432,7 +434,8 @@ AutoencoderModel<TInputValue,NeuronType>
Shark::ListSampleRangeToSharkVector(input, features,startIndex,size); Shark::ListSampleRangeToSharkVector(input, features,startIndex,size);
shark::Data<shark::RealVector> data = shark::createDataFromRange(features); shark::Data<shark::RealVector> data = shark::createDataFromRange(features);
TargetSampleType target; TargetSampleType target;
data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data); // features layer for a network containing the encoder and decoder part // features layer for a network containing the encoder and decoder part
data = m_Net.evalLayer( m_Net.layerMatrices().size()/2-1 ,data);
unsigned int id = startIndex; unsigned int id = startIndex;
target.SetSize(this->m_Dimension); target.SetSize(this->m_Dimension);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment