mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 01:34:22 +00:00
Start dense layer implementation
This commit is contained in:
28
include/layers/conv.h
Normal file
28
include/layers/conv.h
Normal file
@@ -0,0 +1,28 @@
|
||||
// fully_connected_layer.h
|
||||
|
||||
#ifndef CONV_LAYER_H
|
||||
#define CONV_LAYER_H
|
||||
|
||||
#include <cublas_v2.h>
|
||||
|
||||
namespace Layers {
|
||||
|
||||
class Conv {
|
||||
public:
|
||||
Conv(int inputSize, int outputSize, int kernelSize, cublasHandle_t cublasHandle);
|
||||
~Conv();
|
||||
|
||||
void forward(const float* input, float* output);
|
||||
|
||||
private:
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
int kernelSize;
|
||||
cublasHandle_t cublasHandle;
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
|
||||
#endif // CONV_LAYER_H
|
||||
36
include/layers/dense.h
Normal file
36
include/layers/dense.h
Normal file
@@ -0,0 +1,36 @@
|
||||
// fully_connected_layer.h
|
||||
|
||||
#ifndef DENSE_LAYER_H
|
||||
#define DENSE_LAYER_H
|
||||
|
||||
#include <vector>
|
||||
#include <cublas_v2.h>
|
||||
|
||||
namespace Layers {
|
||||
|
||||
class Dense {
|
||||
public:
|
||||
Dense(int inputSize, int outputSize, cublasHandle_t cublasHandle);
|
||||
~Dense();
|
||||
|
||||
void forward(const float* input, float* output);
|
||||
|
||||
private:
|
||||
int inputSize;
|
||||
int outputSize;
|
||||
|
||||
cublasHandle_t cublasHandle;
|
||||
|
||||
float* d_weights;
|
||||
float* d_biases;
|
||||
|
||||
std::vector<std::vector<float>> weights;
|
||||
std::vector<float> biases;
|
||||
|
||||
void initializeWeights();
|
||||
void initializeBiases();
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
|
||||
#endif // DENSE_LAYER_H
|
||||
Reference in New Issue
Block a user