mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-06 01:34:22 +00:00
Add layer name to vector
This commit is contained in:
@@ -15,7 +15,7 @@ Model::Model(const int inputSize, const int inputChannels, const int outputSize)
|
||||
: inputSize(inputSize),
|
||||
inputChannels(inputChannels),
|
||||
outputSize(outputSize),
|
||||
layers(std::vector<Layers::SequentialLayer*>()),
|
||||
layers(std::vector<std::pair<std::string, Layers::SequentialLayer*>>()),
|
||||
layerMap(std::unordered_map<std::string, Layers::SequentialLayer*>()) {
|
||||
inputLayer = new Layers::Input(inputSize * inputSize * inputChannels);
|
||||
outputLayer = new Layers::Output(outputSize);
|
||||
@@ -25,7 +25,7 @@ Model::Model(const Model& other)
|
||||
: inputSize(other.inputSize),
|
||||
inputChannels(other.inputChannels),
|
||||
outputSize(other.outputSize),
|
||||
layers(std::vector<Layers::SequentialLayer*>()),
|
||||
layers(std::vector<std::pair<std::string, Layers::SequentialLayer*>>()),
|
||||
layerMap(std::unordered_map<std::string, Layers::SequentialLayer*>()) {
|
||||
inputLayer = new Layers::Input(*other.inputLayer);
|
||||
outputLayer = new Layers::Output(*other.outputLayer);
|
||||
@@ -34,8 +34,8 @@ Model::Model(const Model& other)
|
||||
Model::~Model() {
|
||||
delete inputLayer;
|
||||
delete outputLayer;
|
||||
for (auto layer : layers) {
|
||||
delete layer;
|
||||
for (const auto& layer : layers) {
|
||||
delete layer.second;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -43,15 +43,15 @@ float* Model::predict(const float* input) {
|
||||
float* d_input = inputLayer->forward(input);
|
||||
|
||||
for (auto& layer : layers) {
|
||||
std::cout << layer << std::endl;
|
||||
d_input = layer->forward(d_input);
|
||||
std::cout << layer.first << std::endl;
|
||||
d_input = layer.second->forward(d_input);
|
||||
}
|
||||
|
||||
return outputLayer->forward(d_input);
|
||||
}
|
||||
|
||||
void Model::addLayer(const std::string& name, Layers::SequentialLayer* layer) {
|
||||
layers.push_back(layer);
|
||||
layers.push_back({ name, layer });
|
||||
layerMap[name] = layer;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user