ruby_brain 0.1.2 → 0.1.3

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.
@@ -14,19 +14,33 @@ module RubyBrain::DataSet::Mnist
14
14
  def data
15
15
  train_images_path = Dir.pwd + '/train-images-idx3-ubyte.gz'
16
16
  train_labels_path = Dir.pwd + '/train-labels-idx1-ubyte.gz'
17
-
17
+ test_images_path = Dir.pwd + '/t10k-images-idx3-ubyte.gz'
18
+ test_labels_path = Dir.pwd + '/t10k-labels-idx1-ubyte.gz'
19
+
18
20
  unless File.exist?(train_images_path)
19
21
  puts 'downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz ...'
20
22
  download_file('http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz', train_images_path)
21
23
  end
22
24
 
23
25
  unless File.exist?(train_labels_path)
24
- puts 'downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz'
26
+ puts 'downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz ...'
25
27
  download_file('http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz', train_labels_path)
26
28
  end
27
29
 
30
+ unless File.exist?(test_images_path)
31
+ puts 'downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz ...'
32
+ download_file('http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz', test_images_path)
33
+ end
34
+
35
+ unless File.exist?(test_labels_path)
36
+ puts 'downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz ...'
37
+ download_file('http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz', test_labels_path)
38
+ end
39
+
28
40
  train_images = Mnist.load_images(train_images_path)
29
41
  train_labels = Mnist.load_labels(train_labels_path)
42
+ test_images = Mnist.load_images(test_images_path)
43
+ test_labels = Mnist.load_labels(test_labels_path)
30
44
 
31
45
  input_training_set = train_images[2].map do |image|
32
46
  image.unpack('C*').map {|e| e / 255.0}
@@ -38,6 +52,16 @@ module RubyBrain::DataSet::Mnist
38
52
  one_hot_vector
39
53
  end
40
54
 
55
+ input_test_set = test_images[2].map do |image|
56
+ image.unpack('C*').map {|e| e / 255.0}
57
+ end
58
+
59
+ output_test_set = test_labels.map do |label|
60
+ one_hot_vector = Array.new(10, 0)
61
+ one_hot_vector[label] = 1
62
+ one_hot_vector
63
+ end
64
+
41
65
  # puts train_images[0].class
42
66
  # puts train_images[1].class
43
67
  # puts train_images[2].size
@@ -55,7 +79,7 @@ module RubyBrain::DataSet::Mnist
55
79
  # puts train_labels[j]
56
80
  # end
57
81
 
58
- {input: input_training_set, output: output_training_set}
82
+ [{input: input_training_set, output: output_training_set}, {input: input_test_set, output: output_test_set}]
59
83
  end
60
84
 
61
85
  module_function :data, :download_file
@@ -1,3 +1,3 @@
1
1
  module RubyBrain
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_brain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - elgoog
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,8 +84,10 @@ files:
84
84
  - Rakefile
85
85
  - bin/console
86
86
  - bin/setup
87
+ - examples/mnist.ipynb
87
88
  - examples/mnist.rb
88
89
  - examples/mnist2.rb
90
+ - examples/wave_form.ipynb
89
91
  - lib/ruby_brain.rb
90
92
  - lib/ruby_brain/dataset/mnist/data.rb
91
93
  - lib/ruby_brain/dataset/mnist/test_mnist.rb