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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f2c52db539548af3d06e7ce7e291d44439f4610b
4
- data.tar.gz: a03adc11a237bec24c7dd0ae8a59cd59ee9ec4b3
3
+ metadata.gz: 140726af26cf5fcdc801e8cbff772004a633ce82
4
+ data.tar.gz: 31a4f48550f4f4c344c991490116d89b5c1476e9
5
5
  SHA512:
6
- metadata.gz: 3608bb2ae571b06ad72c9ed67387c3c436f79b42e4933ef5bf5e9d988e5681afeefb4650c23c964b653faf975774f7e5a14b12caed4baad135be48f55f1cbaf7
7
- data.tar.gz: 5eb96f0af2ae976f8fe1fb35a50fc6134f8e30afd2e92375e07eaaab637db1afebc78df51c9b380a22d0f9bb773ff2637a6b809e86e1b2290b53fa3033adaa78
6
+ metadata.gz: 987df656713a5ea71d144ec684e11f6e0f2a2952fc37ff01363b60ca90b61ea161a2a71a1a8cf75f3fcb11aa9518cbd33bdebac3565fbc290296925fa41f8896
7
+ data.tar.gz: 0c2cbc207eaa4e4792da355ab6f377c29b5e271a8cf6ea08051243e453a30886a3120351a268536183c0f79afb65467b3d3cbf1bed5fccc674299d2e9b906214
data/README.md CHANGED
@@ -19,6 +19,9 @@ network.run [1, 1] # 0.0142
19
19
 
20
20
  ```
21
21
 
22
+ ## Installation
23
+ ``` gem install the_noggin ```
24
+
22
25
  ## Options
23
26
  ``` Ruby
24
27
  Noggin::Network.new(
@@ -5,6 +5,8 @@ module Noggin
5
5
  attr_reader :origins
6
6
  attr_reader :dests
7
7
  attr_accessor :derivative
8
+ attr_accessor :cached_input
9
+ attr_accessor :cached_output
8
10
 
9
11
  def initialize
10
12
  @origins = []
@@ -22,12 +22,13 @@ module Noggin
22
22
  end
23
23
 
24
24
  def derivative_chain
25
- @derivative = input * dest.derivative_chain
26
- @weight * dest.derivative_chain
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: #{@weight.round(6)}, d: #{@derivative.round(6)}"
31
+ "w: #{weight.round(6)}, d: #{derivative.round(6)}"
31
32
  end
32
33
 
33
34
  end
@@ -1,6 +1,7 @@
1
1
  module Noggin
2
2
  class PrettyPrinter
3
3
  def self.print_network layers
4
+ print "\n"
4
5
  grid = []
5
6
  layers.each do |layer|
6
7
  grid << col = []
@@ -1,3 +1,3 @@
1
1
  module Noggin
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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 'sets max max training laps' do
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
- it 'backpropagates error' do
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.1
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-21 00:00:00.000000000 Z
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: