Skip to content

Commit

Permalink
warnings, style here
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael ZBYSZYNSKI committed Nov 14, 2023
1 parent 9f079df commit 143c216
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 274 deletions.
2 changes: 1 addition & 1 deletion src/neuralNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void neuralNetwork<T>::backpropagate(const T& desiredOutput)
}

//deltas between hidden
for (int i = numHiddenLayers - 1; i >= 0; --i)
for (int i { static_cast<int>(numHiddenLayers)- 1 }; i >= 0; --i)
{
for (size_t j = 0; j < numHiddenNodes; ++j)
{
Expand Down
26 changes: 14 additions & 12 deletions src/regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,22 @@ regressionTemplate<T>::regressionTemplate(const std::vector<trainingExampleTempl
};

template<typename T>
std::vector<int> regressionTemplate<T>::getNumHiddenLayers() const
std::vector<size_t> regressionTemplate<T>::getNumHiddenLayers() const
{
std::vector<int> vecNumHiddenLayers;
if (std::begin(modelSet<T>::myModelSet) != std::end(modelSet<T>::myModelSet))
std::vector<size_t> vecNumHiddenLayers;

if (std::begin(modelSet<T>::myModelSet) != std::end(modelSet<T>::myModelSet))
{
for (baseModel<T>* model : modelSet<T>::myModelSet)
for (const baseModel<T>* model : modelSet<T>::myModelSet)
{
neuralNetwork<T>* nnModel = dynamic_cast<neuralNetwork<T>*>(model); //FIXME: I really dislike this design
vecNumHiddenLayers.push_back(nnModel->getNumHiddenLayers());
vecNumHiddenLayers.push_back(dynamic_cast<const neuralNetwork<T>*>(model)->getNumHiddenLayers()); //FIXME: I really dislike this design
}
}
else
{
vecNumHiddenLayers = { numHiddenLayers };
}

return vecNumHiddenLayers;
}

Expand All @@ -96,21 +97,22 @@ void regressionTemplate<T>::setNumHiddenLayers(const int &num_hidden_layers)
}

template<typename T>
std::vector<int> regressionTemplate<T>::getNumHiddenNodes() const
std::vector<size_t> regressionTemplate<T>::getNumHiddenNodes() const
{
std::vector<int> vecNumHiddenNodes;
if (std::begin(modelSet<T>::myModelSet) != std::end(modelSet<T>::myModelSet))
std::vector<size_t> vecNumHiddenNodes;

if (std::begin(modelSet<T>::myModelSet) != std::end(modelSet<T>::myModelSet))
{
for (baseModel<T>* model : modelSet<T>::myModelSet)
for (const baseModel<T>* model : modelSet<T>::myModelSet)
{
neuralNetwork<T>* nnModel = dynamic_cast<neuralNetwork<T>*>(model); //FIXME: I really dislike this design
vecNumHiddenNodes.push_back(nnModel->getNumHiddenNodes());
vecNumHiddenNodes.push_back( dynamic_cast<const neuralNetwork<T>*>(model)->getNumHiddenNodes()); //FIXME: I really dislike this design
}
}
else
{
vecNumHiddenNodes = { numHiddenNodes };
}

return vecNumHiddenNodes;
}

Expand Down
82 changes: 41 additions & 41 deletions src/regression.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,52 @@ template<typename T>
class regressionTemplate final : public modelSet<T>
{
public:
/** with no arguments, just make an empty vector */
regressionTemplate();
/** create based on training set inputs and outputs */
regressionTemplate(const std::vector<trainingExampleTemplate<T> > &trainingSet);
/** create with proper models, but not trained */
regressionTemplate(const int &numInputs, const int &numOutputs);
/** destructor */
~regressionTemplate() {};
/** Train on a specified set, causes creation if not created */
bool train(const std::vector<trainingExampleTemplate<T> > &trainingSet) override;

/** Check how far the training has gotten. Averages progress over all models in training */
float getTrainingProgress();
/** Check how many training epochs each model will run. This feature is temporary, and will be replaced by a different design. */
std::vector<size_t> getNumEpochs() const;
/** Call before train, to set the number of training epochs */
void setNumEpochs(const size_t &epochs);
/** Check how many hidden layers are in each model. This feature is temporary, and will be replaced by a different design. */
std::vector<int> getNumHiddenLayers() const;
/** Set how many hidden layers are in all models. This feature is temporary, and will be replaced by a different design. */
void setNumHiddenLayers(const int &num_hidden_layers);
/** Check how many hidden nodes are in each model. This feature is temporary, and will be replaced by a different design. */
std::vector<int> getNumHiddenNodes() const;
/** Set how many hidden layers are in all models. This feature is temporary, and will be replaced by a different design. */
void setNumHiddenNodes(const int &num_hidden_nodes);
/** with no arguments, just make an empty vector */
regressionTemplate();
/** create based on training set inputs and outputs */
regressionTemplate(const std::vector<trainingExampleTemplate<T> > &trainingSet);
/** create with proper models, but not trained */
regressionTemplate(const int &numInputs, const int &numOutputs);

/** destructor */
~regressionTemplate() {};

/** Train on a specified set, causes creation if not created */
bool train(const std::vector<trainingExampleTemplate<T> > &trainingSet) override;
/** Check how far the training has gotten. Averages progress over all models in training */
float getTrainingProgress();

/** Check how many training epochs each model will run. This feature is temporary, and will be replaced by a different design. */
std::vector<size_t> getNumEpochs() const;

/** Call before train, to set the number of training epochs */
void setNumEpochs(const size_t &epochs);

/** Check how many hidden layers are in each model. This feature is temporary, and will be replaced by a different design. */
std::vector<size_t> getNumHiddenLayers() const;

/** Set how many hidden layers are in all models. This feature is temporary, and will be replaced by a different design. */
void setNumHiddenLayers(const int &num_hidden_layers);

/** Check how many hidden nodes are in each model. This feature is temporary, and will be replaced by a different design. */
std::vector<size_t> getNumHiddenNodes() const;

/** Set how many hidden layers are in all models. This feature is temporary, and will be replaced by a different design. */
void setNumHiddenNodes(const int &num_hidden_nodes);

private:
int numHiddenLayers; //Temporary -- this should be part of the nn class. -mz
size_t numEpochs; //Temporary -- also should be part of nn only. -mz
int numHiddenNodes; //Temporary -- also should be part of nn only. -mz
bool created;
size_t numHiddenLayers { 1 }; //Temporary -- this should be part of the nn class. -mz
size_t numEpochs; //Temporary -- also should be part of nn only. -mz
size_t numHiddenNodes; //Temporary -- also should be part of nn only. -mz
bool created;
};

namespace rapidLib
{
//This is here so the old API still works
using regression = regressionTemplate<double>;
using regressionFloat = regressionTemplate<float>;
//This is here so the old API still works
using regression = regressionTemplate<double>;
using regressionFloat = regressionTemplate<float>;
};

#endif
Loading

0 comments on commit 143c216

Please sign in to comment.