NoJobEngine
2.0.7
Toggle main menu visibility
Loading...
Searching...
No Matches
NeuralEditorPanel.h
Go to the documentation of this file.
1
6
#pragma once
7
#include "
Engine/AI/Neural/NeuralNetwork.h
"
8
#include <atomic>
9
#include <mutex>
10
#include <string>
11
#include <thread>
12
#include <vector>
13
14
namespace
NoJob
{
15
// Editor-only UI. Neural inference/training remains independent of ImGui.
16
class
NeuralEditorPanel
{
17
public
:
18
NeuralEditorPanel
();
19
~NeuralEditorPanel
();
20
NeuralEditorPanel
(
const
NeuralEditorPanel
&) =
delete
;
21
NeuralEditorPanel
&
operator=
(
const
NeuralEditorPanel
&) =
delete
;
22
bool
IsOpen
()
const
{
return
open_; }
23
void
SetOpen
(
bool
open) { open_ = open; }
24
void
Draw
();
25
private
:
26
void
Build();
27
void
StartTraining();
28
void
ResetTrainingSamples();
29
void
StopTraining();
30
void
DrawGraph();
31
void
DrawInspector();
32
void
DrawTraining();
33
void
DrawPredictions();
34
void
FinishWorker();
35
bool
open_ =
false
;
36
Neural::NeuralNetwork
network_;
37
std::vector<int> widths_{2, 4, 1};
38
std::vector<int> activations_{3, 2};
// Tanh, Sigmoid
39
int
selectedLayer_ = 0;
40
int
epochs_ = 3000;
41
int
batchSize_ = 4;
42
float
learningRate_ = 0.04f;
43
bool
adam_ =
true
;
44
char
assetName_[256] =
"Untitled"
;
45
std::string currentName_ =
"Untitled"
;
46
std::string assetMessage_;
47
bool
dirty_ =
true
;
48
bool
restoreAttempted_ =
false
;
49
void
LoadNamed(
const
std::string& name);
50
void
SaveNamed(
const
std::string& name,
bool
saveAs);
51
void
RememberAsset(
const
std::string& name)
const
;
52
void
RestoreLastAsset();
53
char
error_[512] =
""
;
54
std::thread worker_;
55
std::atomic<bool> running_{
false
};
56
std::atomic<bool> cancel_{
false
};
57
std::atomic<int> currentEpoch_{0};
58
std::mutex workerMutex_;
59
std::vector<float> losses_;
60
Neural::NeuralNetwork trained_;
61
bool
resultReady_ =
false
;
62
std::string workerError_;
63
std::vector<float> inputs_{0.f, 1.f};
64
std::vector<std::vector<float>> trainingX_, trainingY_;
65
std::vector<float> lastPrediction_;
66
std::vector<std::vector<float>> lastActivations_;
67
};
68
}
NeuralNetwork.h
Dense neural network inference, training and serialization.
NoJob::Neural::NeuralNetwork
CPU-based feed-forward neural network with native C++ training.
Definition
NeuralNetwork.h:32
NoJob::NeuralEditorPanel::IsOpen
bool IsOpen() const
Definition
NeuralEditorPanel.h:22
NoJob::NeuralEditorPanel::operator=
NeuralEditorPanel & operator=(const NeuralEditorPanel &)=delete
NoJob::NeuralEditorPanel::NeuralEditorPanel
NeuralEditorPanel(const NeuralEditorPanel &)=delete
NoJob::NeuralEditorPanel::SetOpen
void SetOpen(bool open)
Definition
NeuralEditorPanel.h:23
NoJob::NeuralEditorPanel::Draw
void Draw()
Definition
NeuralEditorPanel.cpp:298
NoJob::NeuralEditorPanel::NeuralEditorPanel
NeuralEditorPanel()
Definition
NeuralEditorPanel.cpp:20
NoJob
Definition
BTActionNode.h:13
Editor
Panels
NeuralEditorPanel.h
Generated by
1.18.0