• Stars
    star
    80
  • Rank 391,044 (Top 8 %)
  • Language
    Crystal
  • License
    MIT License
  • Created almost 7 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

FANN (Fast Artifical Neural Network) binding in Crystal

crystal-fann

Join the chat at https://gitter.im/crystal-fann/Lobby

Build Status

Crystal bindings for the FANN C lib

Installation

Add this to your application's shard.yml:

dependencies:
  crystal-fann:
    github: NeuraLegion/crystal-fann

Usage

Look at the spec for most functions

ann = Fann::Network::Standard.new(2, [2], 1)
ann.randomize_weights(0.0, 1.0)
3000.times do
  ann.train_single([1.0, 0.0], [0.5])
end
result = ann.run([1.0, 0.0])
# Remember to close the network when done to free allocated C memory
ann.close
(result < [0.55] && result > [0.45]).should be_true
# Work on array of test data (batch)
ann = Fann::Network::Standard.new(2, [3], 1)
input = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]
output = [[0.0], [1.0], [1.0], [0.0]]
train_data = Fann::TrainData.new(input, output)
data = train_data.train_data
ann.randomize_weights(0.0, 1.0)
if data
  ann.train_batch(data, {:max_runs => 8000, :desired_mse => 0.001, :log_each => 1000})
end
result = ann.run([1.0, 1.0])
ann.close
(result < [0.15]).should be_true
# Work on array of test data using the Cascade2 algorithm (no hidden layers, net will build it alone)
ann = Fann::Network::Cascade.new(2, 1)
input = [[0.0, 0.0], [0.0, 1.0], [1.0, 0.0], [1.0, 1.0]]
output = [[0.0], [1.0], [1.0], [0.0]]
train_data = Fann::TrainData.new(input, output)
data = train_data.train_data
ann.train_algorithm(LibFANN::TrainEnum::TrainRprop)
ann.randomize_weights(0.0, 1.0)
if data
  ann.train_batch(data, {:max_neurons => 500, :desired_mse => 0.001, :log_each => 10})
end
result = ann.run([1.0, 1.0])
ann.close
(result < [0.1]).should be_true

Development

All C lib docs can be found here -> http://libfann.github.io/fann/docs/files/fann-h.html

  • Add TrainData class
  • Add network call method to train on train data
  • Add binding to the 'Parallel' binding to work on multi CPU at same time
  • Clean unneeded bindings in the LibFANN binding
  • Add specific Exceptions
  • Add binding and checks for lib errors

I guess more stuff will be added once more people will use it.

Contributing

  1. Fork it ( https://github.com/NeuraLegion/crystal-fann/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

More Repositories

1

shainet

SHAInet - a pure Crystal machine learning library
Crystal
178
star
2

brokencrystals

A Broken Application - Very Vulnerable!
CSS
103
star
3

cypress-har-generator

Cypress plugin for generating HTTP Archive (HAR) files captures network requests during Cypress tests.
TypeScript
75
star
4

wafalyzer

Web Application Firewall (WAF) Detector
Crystal
32
star
5

har

HAR (HTTP Archive) parser in Crystal
Crystal
22
star
6

broken_crystals

A vulnerable Application in crystal
Crystal
20
star
7

sslscanner

SSL Scanner written in Crystal
Crystal
17
star
8

bright-cli

Command Line Interface (CLI) tool for NeuraLegion's solutions.
TypeScript
16
star
9

sectester-js-demo

This is a demo project for the SecTester JS SDK framework, with some installation and usage examples.
TypeScript
16
star
10

sec-tester-cr

Bright Security scanner integration for Crystal specs
Crystal
14
star
11

tensorflow.cr

TensorFlow bindings in Crystal
Crystal
13
star
12

cvss

The Common Vulnerability Scoring System (CVSS) base score calculator and validator library written in TypeScript.
TypeScript
13
star
13

fix

FIX library for crystal
Crystal
13
star
14

blue_cr

BlueZ bluetooth binding in Crystal
Crystal
12
star
15

sslscan.cr

Crystal shard wrapping the rbsec/sslscan utility
Crystal
10
star
16

generic_actor

A generic Actor model for Crystal
Crystal
10
star
17

har-sdk

HAR SDK enables Node.js developers to easily work with HAR, convert it from OAS/Swagger and Postman collection, and more.
TypeScript
9
star
18

mt_helpers

MultiThreading helpers for crystal
Crystal
8
star
19

example-actions

8
star
20

monitor

Quick HTTP Load tester for CSE\Support
Crystal
5
star
21

sectester-js

SecTester is a new tool that integrates our enterprise-grade scan engine directly into your unit tests.
TypeScript
4
star
22

documentation

NeuraLegion's Documentation Repository
4
star
23

simple-email

Crystal
3
star
24

jfrog-example

3
star
25

changelog

NexPloit Changelog
2
star
26

run-scan

Action runs a new security scan in NeuraLegion, or reruns an existing one
TypeScript
2
star
27

AMASS-the-Legion

Python
2
star
28

crometheus

Crystal
2
star
29

oas2har

Transform you Swagger/OAS spec files to a series of HAR request objects.
JavaScript
2
star
30

socket_io

Crystal SocketIO Shard
Crystal
2
star
31

postman2har

Transform your Postman collection to a series of HAR request objects.
TypeScript
2
star
32

broken_crystals_kemal

Temporary backup of Broken Crystals written in Kemal
HTML
1
star
33

restharter

Restart a scan using a HAR
Crystal
1
star
34

sectester-net

SecTester is a new tool that integrates our enterprise-grade scan engine directly into your unit tests.
C#
1
star
35

helmcharts

Smarty
1
star