更新時(shí)間:2022-06-27 16:13:03 來源:動(dòng)力節(jié)點(diǎn) 瀏覽1769次
簡(jiǎn)單神經(jīng)網(wǎng)絡(luò)是一個(gè) Java 項(xiàng)目,允許用戶輕松創(chuàng)建異步簡(jiǎn)單神經(jīng)網(wǎng)絡(luò)。
該項(xiàng)目可用于根據(jù)初始學(xué)習(xí)預(yù)測(cè)輸出。
使用結(jié)果實(shí)體回調(diào)
可定制的神經(jīng)元數(shù)量
從外部文件讀取數(shù)據(jù)
簡(jiǎn)單的預(yù)測(cè)器使用
這是默認(rèn)配置的簡(jiǎn)單用法:
1.首先,加載輸入和輸出數(shù)據(jù)。您可以從外部文本文件中讀取它:
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.使用來自成功響應(yīng)的 Result 實(shí)體預(yù)測(cè)一個(gè)值:
@Override
public void success(Result result) {
float[] valueToPredict = new float[] {-1.2f, 0.796f};
System.out.println("Predicted result: " + result.predictValue(valueToPredict));
}
4.最后,運(yùn)行神經(jīng)網(wǎng)絡(luò)的學(xué)習(xí):
神經(jīng)網(wǎng)絡(luò).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
您可以自定義一些值作為神經(jīng)元的數(shù)量、bucle 迭代限制、傳遞函數(shù)和結(jié)果解析器。
該項(xiàng)目有一個(gè)包含真實(shí)數(shù)據(jù)的示例,其中包含 250 名患者的列表,其中兩個(gè)分析結(jié)果作為輸入,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
... ... ...
使用神經(jīng)網(wǎng)絡(luò)中的這些數(shù)據(jù),該項(xiàng)目能夠以88%的最小成功率預(yù)測(cè)不在數(shù)據(jù)列表中的患者的輸出(疾病結(jié)果)。
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.
相關(guān)閱讀
Java實(shí)驗(yàn)班
0基礎(chǔ) 0學(xué)費(fèi) 15天面授
Java就業(yè)班
有基礎(chǔ) 直達(dá)就業(yè)
Java夜校直播班
業(yè)余時(shí)間 高薪轉(zhuǎn)行
Java在職加薪班
工作1~3年,加薪神器
Java架構(gòu)師班
工作3~5年,晉升架構(gòu)
提交申請(qǐng)后,顧問老師會(huì)電話與您溝通安排學(xué)習(xí)