mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 01:34:22 +00:00
Initialize conv2d layer
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
#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
|
||||
60
include/layers/conv2d.cuh
Normal file
60
include/layers/conv2d.cuh
Normal file
@@ -0,0 +1,60 @@
|
||||
#ifndef CONV_LAYER_H
|
||||
#define CONV_LAYER_H
|
||||
|
||||
#include <cublas_v2.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "activations.cuh"
|
||||
|
||||
namespace Layers {
|
||||
|
||||
class Conv2d {
|
||||
public:
|
||||
Conv2d(
|
||||
int inputSize,
|
||||
int inputChannels,
|
||||
int kernelSize,
|
||||
int stride,
|
||||
std::string padding,
|
||||
int numFilters,
|
||||
Activation activation,
|
||||
cublasHandle_t cublasHandle
|
||||
);
|
||||
~Conv2d();
|
||||
|
||||
void forward(const float* d_input, float* d_output);
|
||||
|
||||
private:
|
||||
// Inputs
|
||||
int inputSize;
|
||||
int inputChannels;
|
||||
|
||||
// Kernel
|
||||
int kernelSize;
|
||||
int stride;
|
||||
int paddingSize;
|
||||
int numFilters;
|
||||
|
||||
// Outputs
|
||||
int outputSize;
|
||||
|
||||
// Kernels
|
||||
std::vector<float> kernels;
|
||||
|
||||
// Cuda
|
||||
cublasHandle_t cublasHandle;
|
||||
float* d_kernels;
|
||||
float* d_padded;
|
||||
|
||||
// Kernels
|
||||
Activation activation;
|
||||
|
||||
void initializeKernels();
|
||||
void toCuda();
|
||||
};
|
||||
|
||||
} // namespace Layers
|
||||
|
||||
#endif // CONV_LAYER_H
|
||||
@@ -21,7 +21,7 @@ class Dense : public ILayer {
|
||||
);
|
||||
~Dense();
|
||||
|
||||
void forward(const float* input, float* output);
|
||||
void forward(const float* d_input, float* d_output);
|
||||
void setWeights(const std::vector<std::vector<float>>& weights);
|
||||
void setBiases(const std::vector<float>& biases);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user