-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackend.cpp
More file actions
41 lines (37 loc) · 1.29 KB
/
backend.cpp
File metadata and controls
41 lines (37 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "backend.h"
#include "json_utils.h"
#include "codegenerator.h"
#include "programfragmentprocessor.h"
#include <QJsonObject>
#include <QJsonDocument>
#include <QDebug>
QJsonObject NeuralLayer::toJsonObject() const {//将NeuralLayer对象转化为QJsonObject对象
QJsonObject obj;
obj["layerType"] = layerType;
obj["neurons"] = neurons;
obj["dropoutRate"] = dropoutRate;
obj["poolingSize"] = poolingSize;
obj["activationFunction"] = activationFunction;
return obj;
}
NeuralLayer::NeuralLayer() {
layerType = "";
neurons = 0;
dropoutRate=0.5f;
poolingSize=4;
activationFunction = "";
filters = 32;
kernelSize = 5;
units = 128;
}
NeuralLayer NeuralLayer::fromJsonObject(const QJsonObject& obj) {//将QJsonObject对象转化为NeuralLayer对象
NeuralLayer layer;
if (!obj.contains("layerType") ||!obj.contains("neurons") ||!obj.contains("activationFunction")) {
qDebug() << "Error form fromJsonObject: Missing required fields in JSON object when converting to NeuralLayer.";
return layer;
}
layer.layerType = obj["layerType"].toString();
layer.neurons = obj["neurons"].toInt();
layer.activationFunction = obj["activationFunction"].toString();
return layer;
}