mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-05 17:34:21 +00:00
39 lines
735 B
C++
39 lines
735 B
C++
// fully_connected_layer.h
|
|
|
|
#ifndef DENSE_LAYER_H
|
|
#define DENSE_LAYER_H
|
|
|
|
#include <vector>
|
|
#include <cublas_v2.h>
|
|
#include <ilayer.h>
|
|
|
|
namespace Layers {
|
|
|
|
class Dense : public ILayer {
|
|
public:
|
|
Dense(int inputSize, int outputSize, cublasHandle_t cublasHandle);
|
|
~Dense();
|
|
|
|
void forward(const float* input, float* output);
|
|
void to_cuda();
|
|
|
|
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
|