8abdea6b77
Co-authored-by: Copilot <copilot@github.com>
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#ifndef CORE_H
|
|
#define CORE_H
|
|
|
|
#include "typedef.hpp"
|
|
#include <vector>
|
|
#include <cmath>
|
|
#include "core.hpp"
|
|
#include <cstdlib>
|
|
#include <omp.h>
|
|
#include <vulkan/vulkan.hpp>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
class NeuralNetwork {
|
|
private:
|
|
int numLayers;
|
|
std::vector<int> sizes;
|
|
std::vector<std::vector<std::vector<double>>> weights;
|
|
std::vector<std::vector<double>> biases;
|
|
std::vector<std::vector<double>> outputs;
|
|
|
|
vk::Instance instance;
|
|
vk::PhysicalDevice physDev;
|
|
vk::Device device;
|
|
vk::Queue queue;
|
|
vk::CommandPool cmdPool;
|
|
|
|
uint32_t NeuralNetwork::findMemoryType(uint32_t typeFilter, vk::MemoryPropertyFlags properties);
|
|
|
|
double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); }
|
|
double sigmoidDeriv(double x) { return x * (1.0 - x); }
|
|
|
|
public:
|
|
int cpu_count = 1;
|
|
NeuralNetwork(LayerStructure_t layers[], int count, bool useVulkan = false);
|
|
std::vector<double> feedForward(const std::vector<double>& input);
|
|
double train(const std::vector<double>& input, const std::vector<double>& target, double lr);
|
|
double trainVulkan();
|
|
};
|
|
|
|
#endif |