NoJobEngine 2.0.7
Loading...
Searching...
No Matches
NeuralEditorPanel.h
Go to the documentation of this file.
1
6#pragma once
8#include <atomic>
9#include <mutex>
10#include <string>
11#include <thread>
12#include <vector>
13
14namespace NoJob {
15// Editor-only UI. Neural inference/training remains independent of ImGui.
17public:
22 bool IsOpen() const { return open_; }
23 void SetOpen(bool open) { open_ = open; }
24 void Draw();
25private:
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}
Dense neural network inference, training and serialization.
CPU-based feed-forward neural network with native C++ training.
NeuralEditorPanel & operator=(const NeuralEditorPanel &)=delete
NeuralEditorPanel(const NeuralEditorPanel &)=delete