the_noggin 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/noggin/node/base.rb +2 -0
- data/lib/noggin/node/edge.rb +4 -3
- data/lib/noggin/pretty_printer.rb +1 -0
- data/lib/noggin/version.rb +1 -1
- data/noggin.gemspec +24 -0
- data/spec/network_spec.rb +23 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140726af26cf5fcdc801e8cbff772004a633ce82
|
4
|
+
data.tar.gz: 31a4f48550f4f4c344c991490116d89b5c1476e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 987df656713a5ea71d144ec684e11f6e0f2a2952fc37ff01363b60ca90b61ea161a2a71a1a8cf75f3fcb11aa9518cbd33bdebac3565fbc290296925fa41f8896
|
7
|
+
data.tar.gz: 0c2cbc207eaa4e4792da355ab6f377c29b5e271a8cf6ea08051243e453a30886a3120351a268536183c0f79afb65467b3d3cbf1bed5fccc674299d2e9b906214
|
data/README.md
CHANGED
data/lib/noggin/node/base.rb
CHANGED
data/lib/noggin/node/edge.rb
CHANGED
@@ -22,12 +22,13 @@ module Noggin
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def derivative_chain
|
25
|
-
|
26
|
-
@
|
25
|
+
derivative_chain = dest.derivative_chain
|
26
|
+
@derivative = input * derivative_chain
|
27
|
+
weight * derivative_chain
|
27
28
|
end
|
28
29
|
|
29
30
|
def pretty_print
|
30
|
-
"w: #{
|
31
|
+
"w: #{weight.round(6)}, d: #{derivative.round(6)}"
|
31
32
|
end
|
32
33
|
|
33
34
|
end
|
data/lib/noggin/version.rb
CHANGED
data/noggin.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'noggin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'the_noggin'
|
8
|
+
spec.version = Noggin::VERSION
|
9
|
+
spec.authors = ['Shawn']
|
10
|
+
spec.email = ['shaw3257@gmail.com']
|
11
|
+
spec.description = 'Ruby Neural Network implementation using backpropagation and gradient descent for training'
|
12
|
+
spec.summary = 'Pass in training samples, and the network will try to find pathways that lead to the least amount of error. The network is customizable in that it let’s you control the learning rate, hidden layer size and depth, and max training iterations.'
|
13
|
+
spec.homepage = 'https://github.com/shaw3257/noggin'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.4'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
24
|
+
end
|
data/spec/network_spec.rb
CHANGED
@@ -9,8 +9,8 @@ describe Noggin::Network do
|
|
9
9
|
let(:output_node) { subject.layers[2].first }
|
10
10
|
|
11
11
|
before do
|
12
|
+
allow_any_instance_of(Noggin::Node::Edge).to receive(:weight).and_return(0.66)
|
12
13
|
subject.train [{ input: [1], output: 0 }]
|
13
|
-
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'sets up the network graph according to settings' do
|
@@ -26,12 +26,30 @@ describe Noggin::Network do
|
|
26
26
|
expect(subject.layers[1].size).to eq(1)
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
30
|
-
|
29
|
+
it 'backpropagates error' do
|
30
|
+
expect(input_node.dests.first.derivative).to be_within(0.00001).of(0.02147)
|
31
|
+
expect(hidden_node.dests.first.derivative).to be_within(0.00001).of(0.095468)
|
31
32
|
end
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe :xor do
|
38
|
+
|
39
|
+
subject { Noggin::Network.new( max_training_laps: 10000, learning_rate: 0.1, hidden_layer_size: 1, hidden_layer_node_size: 2 ) }
|
40
|
+
|
41
|
+
|
42
|
+
before do
|
43
|
+
subject.train([
|
44
|
+
{ input: [0, 0], output: 0 },
|
45
|
+
{ input: [0, 1], output: 1 },
|
46
|
+
{ input: [1, 0], output: 1 },
|
47
|
+
{ input: [1, 1], output: 0 }
|
48
|
+
])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'learns xor' do
|
52
|
+
subject.pretty_print
|
35
53
|
end
|
36
54
|
|
37
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: the_noggin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shawn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- lib/noggin/node/output.rb
|
74
74
|
- lib/noggin/pretty_printer.rb
|
75
75
|
- lib/noggin/version.rb
|
76
|
+
- noggin.gemspec
|
76
77
|
- spec/network_spec.rb
|
77
78
|
homepage: https://github.com/shaw3257/noggin
|
78
79
|
licenses:
|