mnist-learn 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 504c344a2c988dabc88a999e39ddf1606d933104
4
- data.tar.gz: 0f14af637ecba647edd55029b2ed31f3736f8ad4
3
+ metadata.gz: f7c32173c9b2cad0727cad6c42fbcbe2e26ee018
4
+ data.tar.gz: fa38db0274728e2c9cc8e485df204170e7975314
5
5
  SHA512:
6
- metadata.gz: a46c24443968425589a876d8057a8343ecd42c5afcf417e732006927c2ea3578fad1823be83a7913550b2c420a20e8f395c9e3dea781d58dcdab0dfd677f5cfe
7
- data.tar.gz: 7761897fa21b0c0503adf09a385563bb4951087cb60d843ecc1549f1309f22c6d0ba85749e05d710b42dc48f71a54ebc3eb9f1f90b21bd81705fe76e783be670
6
+ metadata.gz: 7e5d3ae3edf48bbf64d435d13f779373c164cbe5e657dabeec37ce365251aa159f8298697bbd48cb05dd81d6440772fd7e7a411ebf5fb1495f064ebd0aea8a54
7
+ data.tar.gz: 389b4d54998861186d77fba7772fdde0ff29a284ad011ef7f4a167fc8e8a61bddeea1fb06d42a5d6630a49b98469d5f1a5bdefffa3e9b19f64a8e7e42bea4686
data/lib/mnist-learn.rb CHANGED
@@ -69,7 +69,7 @@ module Mnist
69
69
  @all_labels ||= (@one_hot ? load_labels.map { |label_data| one_hot_transform(label_data) } : load_labels)
70
70
  end
71
71
 
72
- def next_batch(batch_size)
72
+ def next(batch_size)
73
73
  if @index == 0
74
74
  @rows, @columns, @images = load_images
75
75
  @labels = load_labels
@@ -87,6 +87,23 @@ module Mnist
87
87
  end
88
88
  [images, labels]
89
89
  end
90
+
91
+ def next_batch(batch_size, rnd: Random.new)
92
+ @data_set ||= begin
93
+ rows, columns, images = load_images
94
+ labels = load_labels
95
+ Array.new(images.size) do
96
+ image_data = images[@index]
97
+ label_data = labels[@index]
98
+ image_data.map! { |b| b.to_f / 255.0 }
99
+ @index += 1
100
+ [image_data, (@one_hot ? one_hot_transform(label_data) : label_data.to_f)]
101
+ end
102
+ end
103
+ @data_set.shuffle!(random: rnd)
104
+ batch = @data_set[0...batch_size]
105
+ [batch.map { |v| v[0]}, batch.map { |v| v[1]}]
106
+ end
90
107
 
91
108
  private
92
109
 
@@ -1,3 +1,3 @@
1
1
  module Mnist
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnist-learn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Dayo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-29 00:00:00.000000000 Z
11
+ date: 2018-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.6.8
125
+ rubygems_version: 2.2.2
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Utilities for MNIST handwritten digits data