cleaning + Network getter and setter for input / output size
This commit is contained in:
@@ -9,48 +9,61 @@
|
||||
|
||||
#define NEURAL_NETWORK_INIT() const static bool ______TMP= NeuralNetwork::Network::loaded()
|
||||
|
||||
namespace NeuralNetwork
|
||||
{
|
||||
namespace NeuralNetwork {
|
||||
|
||||
/**
|
||||
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
||||
* @brief Abstract model of simple Network
|
||||
*/
|
||||
class Network : public SimpleJSON::SerializableObject
|
||||
{
|
||||
class Network : public SimpleJSON::SerializableObject {
|
||||
public:
|
||||
/**
|
||||
* @brief Constructor for Network
|
||||
*/
|
||||
inline Network() {
|
||||
inline Network(std::size_t inputs, std::size_t outputs) : _inputs(inputs), _outputs(outputs) {
|
||||
loaded();
|
||||
};
|
||||
|
||||
Network(const Network &r) = default;
|
||||
|
||||
/**
|
||||
* @brief Virtual destructor for Network
|
||||
*/
|
||||
virtual ~Network() {};
|
||||
virtual ~Network() { };
|
||||
|
||||
/**
|
||||
* @brief This is a virtual function for all networks
|
||||
* @param input is input of network
|
||||
* @returns output of network
|
||||
*/
|
||||
virtual std::vector<float> computeOutput(const std::vector<float>& input)=0;
|
||||
virtual std::vector<float> computeOutput(const std::vector<float> &input) = 0;
|
||||
|
||||
std::size_t inputs() {
|
||||
return _inputs;
|
||||
}
|
||||
|
||||
|
||||
std::size_t outputs() {
|
||||
return _outputs;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param t is number of threads, if set to 0 or 1 then threading is disabled
|
||||
* @param threads is number of threads, if set to 0 or 1 then threading is disabled
|
||||
* @brief Enables or disables Threaded computing of ANN
|
||||
*/
|
||||
|
||||
inline virtual void setThreads(const unsigned& t) final {threads=t;}
|
||||
inline virtual void setThreads(const unsigned &threads) final {
|
||||
_threads = threads;
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Number of threads used by network
|
||||
*/
|
||||
unsigned threads=1;
|
||||
unsigned _threads = 1;
|
||||
|
||||
std::size_t _inputs;
|
||||
std::size_t _outputs;
|
||||
public:
|
||||
static bool loaded();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user