70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include "Neuron.h"
|
|
|
|
#include <SimpleJSON/SerializableObject.h>
|
|
|
|
#include <cstddef>
|
|
#include <vector>
|
|
|
|
#define NEURAL_NETWORK_INIT() const static bool ______TMP= NeuralNetwork::Network::loaded()
|
|
|
|
namespace NeuralNetwork {
|
|
|
|
/**
|
|
* @author Tomas Cernik (Tom.Cernik@gmail.com)
|
|
* @brief Abstract model of simple Network
|
|
*/
|
|
class Network : public SimpleJSON::SerializableObject {
|
|
public:
|
|
/**
|
|
* @brief Constructor for 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() { };
|
|
|
|
/**
|
|
* @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;
|
|
|
|
std::size_t inputs() {
|
|
return _inputs;
|
|
}
|
|
|
|
|
|
std::size_t outputs() {
|
|
return _outputs;
|
|
}
|
|
|
|
/**
|
|
* @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 &threads) final {
|
|
_threads = threads;
|
|
}
|
|
|
|
protected:
|
|
/**
|
|
* @brief Number of threads used by network
|
|
*/
|
|
unsigned _threads = 1;
|
|
|
|
std::size_t _inputs;
|
|
std::size_t _outputs;
|
|
public:
|
|
static bool loaded();
|
|
};
|
|
} |