mirror of
https://github.com/lxsang/antd-lua-plugin
synced 2025-09-03 17:52:10 +02:00
mimgrating from another repo
This commit is contained in:
14
lib/ann/examples/cascade/test.lua
Executable file
14
lib/ann/examples/cascade/test.lua
Executable file
@@ -0,0 +1,14 @@
|
||||
#! /usr/bin/env lua
|
||||
|
||||
require("lfann")
|
||||
|
||||
-- Load the network from a file
|
||||
local net = fann.Net.create_from_file("xor.net")
|
||||
|
||||
-- Test using command line args
|
||||
local input = {arg[1] and tonumber(arg[1]) or 1, arg[1] and tonumber(arg[2]) or 0}
|
||||
local output = net:run(input)
|
||||
|
||||
for i, j in ipairs(output) do
|
||||
print(j)
|
||||
end
|
9
lib/ann/examples/cascade/train.data
Normal file
9
lib/ann/examples/cascade/train.data
Normal file
@@ -0,0 +1,9 @@
|
||||
4 2 1
|
||||
1 1
|
||||
0
|
||||
1 0
|
||||
1
|
||||
0 1
|
||||
1
|
||||
0 0
|
||||
0
|
13
lib/ann/examples/cascade/train.lua
Executable file
13
lib/ann/examples/cascade/train.lua
Executable file
@@ -0,0 +1,13 @@
|
||||
#! /usr/bin/env lua
|
||||
|
||||
require("lfann")
|
||||
|
||||
-- Create a shortcut neural network to serve as base to the cascade training
|
||||
local net = fann.Net.create_shortcut{2, 1}
|
||||
|
||||
-- Train the net from a file
|
||||
net:set_train_stop_function(fann.STOPFUNC_MSE)
|
||||
net:cascade_train_on_file("train.data", 10, 1, 0.0001)
|
||||
|
||||
-- Save the net to a file for a latter execution
|
||||
net:save("xor.net");
|
Reference in New Issue
Block a user