mnist-ready 1.1.1 → 1.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mnist_dataset.rb +11 -9
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4b2b0059fb779cef3b208d6b061f44cf0276050bf2ab03c7ba35d26433bdb119
4
- data.tar.gz: 964e0569bd60637da0c376d054358a9ed70512942f238231050533a1028dab40
3
+ metadata.gz: 7696501a6c74718d41b63494e633f6f6b73be2372956fa9cb1d0fd084d4837a3
4
+ data.tar.gz: 94261b6706c88f049359a1d88ee667fd75b5df407c93e10d9ee5a6277d0437e4
5
5
  SHA512:
6
- metadata.gz: bf6e5fda8c12fb6dac08c923db72c32b3948bfeb432c03310f88dd711a54d85b847a4c124b5d1787f98f115ff7186601b0c2472cd37c8a5fdbca3e1fc8ae8bab
7
- data.tar.gz: 3622880f3bafe45b3b621221ebfa9c3f02459c9a76551898c38efdef3087cb1cc74b411bf0889e76b3f4081c01a95d2c714c73ebf52ea5eac1c96128fbf57904
6
+ metadata.gz: 0bc784b1a75a6cdb9be706d2d5017f670cabc8ab371205d4d2d84f45c145e74269503a29f61c8371c1b86b4184b7308d443c23c564fb1d1d7664633d3722115a
7
+ data.tar.gz: a889be91d16e0eed699f5ec1298c13a3225ea355a074cc44d0c057776bc696040f790494d18f1643f3d5cd1a2b8591784680486fcde88bc5bdc4a73fac023aef
data/lib/mnist_dataset.rb CHANGED
@@ -11,7 +11,7 @@ class MnistDataset
11
11
 
12
12
  private_class_method :new
13
13
 
14
- def initialize(show_progress)
14
+ def initialize(show_progress, just_one)
15
15
  test_set = File.join(File.dirname(__FILE__), '..', 'data', 'mnist_test.csv')
16
16
 
17
17
  @train_set = []
@@ -24,6 +24,7 @@ class MnistDataset
24
24
  @test_set.push(digit)
25
25
  @all_set.push(digit)
26
26
  print "\r#{all_set.size}" if show_progress
27
+ break if just_one
27
28
  end
28
29
 
29
30
  (1..3).each do |index|
@@ -34,17 +35,19 @@ class MnistDataset
34
35
  @train_set.push(digit)
35
36
  @all_set.push(digit)
36
37
  print "\r#{all_set.size}" if show_progress
38
+ break if just_one
37
39
  end
40
+ break if just_one
38
41
  end
39
42
  puts if show_progress
40
43
  end
41
44
 
42
45
  attr_reader :all_set, :train_set, :test_set
43
46
 
44
- def self.instance(show_progress = false)
47
+ def self.instance(show_progress = false, just_one = false)
45
48
  return @instance if @instance
46
49
  @instance_mutex.synchronize do
47
- @instance ||= new(show_progress)
50
+ @instance ||= new(show_progress, just_one)
48
51
  end
49
52
  @instance
50
53
  end
@@ -97,13 +100,12 @@ class MnistDataset
97
100
 
98
101
  def count_digits(hash)
99
102
  count = {}
103
+ (0..9).each do |label|
104
+ count[label] = 0
105
+ end
100
106
  hash.each do |digit|
101
- label = digit.label
102
- if count.has_key?(label)
103
- count[label] = count[label] + 1
104
- else
105
- count[label] = 1
106
- end
107
+ label = digit.label
108
+ count[label] = count[label] + 1
107
109
  end
108
110
  count
109
111
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnist-ready
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Oliveira Jr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-02 00:00:00.000000000 Z
11
+ date: 2024-09-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: sergio.oliveira.jr@gmail.com
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
42
  - !ruby/object:Gem::Version
43
43
  version: '0'
44
44
  requirements: []
45
- rubygems_version: 3.4.7
45
+ rubygems_version: 3.4.22
46
46
  signing_key:
47
47
  specification_version: 4
48
48
  summary: A simple and straightforward Ruby library that handles everything related