← Back

ofxNeuralGraph

github.com/tettou771/ofxNeuralGraph · @tettou771
OF 0.12 Machine Learning Artificial Intelligence

Header-only graph-based neural network library with template activation functions, backpropagation learning, and JSON save/load.

0 0 Last commit 1y ago Created 1y ago

README

ofxNeuralGraph



openFrameworks用のグラフベースニューラルネットワークライブラリ

特徴



使用方法



#include "ofxNeuralGraph.h"

// ニューラルグラフを作成
ofxNeuralGraph::ofxNeuralGraph graph;

// 入力ニューロンを作成(Linear活性化関数)
vector<int> inputs;
inputs.push_back(graph.makeNeuron<ofxNeuralGraph::Linear>({}));
inputs.push_back(graph.makeNeuron<ofxNeuralGraph::Linear>({}));

// 隠れ層を作成(Sigmoid活性化関数)
vector<int> hidden;
graph.makeManyNeurons<ofxNeuralGraph::Sigmoid>(inputs, 3, hidden);

// 出力ニューロンを作成(Sigmoid活性化関数)
int output = graph.makeNeuron<ofxNeuralGraph::Sigmoid>(hidden);

// 重みとバイアスを初期化
graph.randomizeWeights(-0.5f, 0.5f);
graph.randomizeBiases(0.0f, 0.0f);

// 学習率を設定
graph.setLearningRate(0.1f);

// 学習ループ
graph.setInputs({{inputs[0], 0.0f}, {inputs[1], 1.0f}});
graph.forward();
float result = graph.getOutput(output);
graph.backward({{output, targetValue}});
graph.updateWeights();

// ネットワークを保存/読み込み
graph.save("network.json");
graph.load("network.json");


活性化関数



サンプル



example-basic: XOR問題の学習と可視化



操作方法

インストール



1. このリポジトリをopenFrameworksのaddonsフォルダに配置 2. プロジェクトジェネレーターでexample-basicをインポート 3. ofxNeuralGraphアドオンを追加 4. ビルド・実行

ファイル構造



ofxNeuralGraph/
├── src/
│   ├── ofxNeuralGraph.h          # メインクラス
│   ├── ofxNeuron.h               # ニューロンクラス
│   └── ofxActivationFunctions.h  # 活性化関数群
├── example-basic/                # XORサンプル
│   ├── addons.make
│   ├── src/
│   │   ├── main.cpp
│   │   ├── ofApp.h
│   │   └── ofApp.cpp
│   └── bin/data/
├── README.md
└── CLAUDE.md                     # 開発指示書


技術仕様



ライセンス



MIT

Get this addon

HTTPS
SSH