1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2025-07-26 10:49:51 +02:00

mimgrating from another repo

This commit is contained in:
Xuan Sang LE
2018-09-19 15:08:49 +02:00
parent 91320521e8
commit 38bd13b46b
600 changed files with 362490 additions and 1 deletions

41
lib/ann/examples/xor/test.lua Executable file
View File

@ -0,0 +1,41 @@
#! /usr/bin/env lua
-- load the library
require("lfann")
-- load the network from the exported file
local net = fann.Net.create_from_file("xor.net")
local n_input, n_output = 2, 1
local input, output = {}
local write, sf = io.write, string.format
-- test using the stdio (enter q to quit)
while true do
local cont = true
-- input
for i = 1, n_input do
local aux = io.read("*n")
if not aux then
cont = false
break
end
input[i] = aux
end
if not cont then break end
-- run the network
output = net:run(input)
-- output
for i = 1, n_output do
if i > 1 then write(" ") end
write( sf("%.6f", output[i]) )
end
write("\n")
end

View File

@ -0,0 +1,9 @@
4 2 1
1 1
-1
1 -1
1
-1 1
1
-1 -1
-1

17
lib/ann/examples/xor/train.lua Executable file
View File

@ -0,0 +1,17 @@
#! /usr/bin/env lua
require("lfann")
-- Create a Neural Network with tree layers, with 2, 3 and 1 neurons, plus one
-- bias neuron per layer
local net = fann.Net.create_standard{2, 3, 1}
-- Configure the activation function
net:set_activation_function_hidden(fann.GAUSSIAN_SYMMETRIC)
net:set_activation_function_output(fann.GAUSSIAN_SYMMETRIC)
-- Train the net from a file
net:train_on_file("train.data", 1000, 10, 0.0001)
-- Save the net to a file for a latter execution
net:save("xor.net");