更新時間:2022-06-27 16:13:03 來源:動力節點 瀏覽1342次
簡單神經網絡是一個 Java 項目,允許用戶輕松創建異步簡單神經網絡。
該項目可用于根據初始學習預測輸出。
使用結果實體回調
可定制的神經元數量
從外部文件讀取數據
簡單的預測器使用
這是默認配置的簡單用法:
1.首先,加載輸入和輸出數據。您可以從外部文本文件中讀取它:
float[][] x = DataUtils.readInputsFromFile("data/x.txt"); int[] t = DataUtils.readOutputsFromFile("data/t.txt");
2.
Instantiate new NeuralNetwork and create a new callback to receive response:java NeuralNetwork neuralNetwork = new NeuralNetwork(x, t, new INeuralNetworkCallback() { @Override public void success(Result result) { }
@Override
public void failure(Error error) {
}
});
```
3.使用來自成功響應的 Result 實體預測一個值:
@Override
public void success(Result result) {
float[] valueToPredict = new float[] {-1.2f, 0.796f};
System.out.println("Predicted result: " + result.predictValue(valueToPredict));
}
4.最后,運行神經網絡的學習:
神經網絡.startLearning(); ```
完整示例:
float[][] x = DataUtils.readInputsFromFile("data/x.txt");
int[] t = DataUtils.readOutputsFromFile("data/t.txt");
NeuralNetwork neuralNetwork = new NeuralNetwork(x, t, new INeuralNetworkCallback() {
@Override
public void success(Result result) {
float[] valueToPredict = new float[] {-0.205f, 0.780f};
System.out.println("Success percentage: " + result.getSuccessPercentage());
System.out.println("Predicted result: " + result.predictValue(valueToPredict));
}
@Override
public void failure(Error error) {
System.out.println("Error: " + error.getDescription());
}
});
neuralNetwork.startLearning();
輸出:
Success percentage: 88.4
Predicted result: 1
您可以自定義一些值作為神經元的數量、bucle 迭代限制、傳遞函數和結果解析器。
該項目有一個包含真實數據的示例,其中包含 250 名患者的列表,其中兩個分析結果作為輸入,0 或 1(取決于是否患有疾病)作為輸出:
Inputs Output
------------------------ --------------------
Result 1 Result 2 Disease
----------------------- --------------------
-0.5982 0.9870 1
-0.2019 0.6210 1
0.1797 0.4518 0
-0.0982 0.5876 1
... ... ...
使用神經網絡中的這些數據,該項目能夠以88%的最小成功率預測不在數據列表中的患者的輸出(疾病結果)。
Copyright 2014 José Luis Martín
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
0基礎 0學費 15天面授
有基礎 直達就業
業余時間 高薪轉行
工作1~3年,加薪神器
工作3~5年,晉升架構
提交申請后,顧問老師會電話與您溝通安排學習