mnist-ready 1.0.2 → 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.
- checksums.yaml +4 -4
- data/lib/mnist_dataset.rb +18 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7696501a6c74718d41b63494e633f6f6b73be2372956fa9cb1d0fd084d4837a3
|
4
|
+
data.tar.gz: 94261b6706c88f049359a1d88ee667fd75b5df407c93e10d9ee5a6277d0437e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc784b1a75a6cdb9be706d2d5017f670cabc8ab371205d4d2d84f45c145e74269503a29f61c8371c1b86b4184b7308d443c23c564fb1d1d7664633d3722115a
|
7
|
+
data.tar.gz: a889be91d16e0eed699f5ec1298c13a3225ea355a074cc44d0c057776bc696040f790494d18f1643f3d5cd1a2b8591784680486fcde88bc5bdc4a73fac023aef
|
data/lib/mnist_dataset.rb
CHANGED
@@ -4,14 +4,14 @@ require 'json'
|
|
4
4
|
|
5
5
|
class MnistDataset
|
6
6
|
|
7
|
-
@@VERSION = "1.
|
7
|
+
@@VERSION = "1.1.1"
|
8
8
|
@@YEAR = "2023"
|
9
9
|
|
10
10
|
@instance_mutex = Mutex.new
|
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,21 +35,28 @@ 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
|
51
54
|
|
55
|
+
# very important to override this otherwise inspect will go crazy trying to inspect 70000 elements
|
56
|
+
def inspect
|
57
|
+
to_s
|
58
|
+
end
|
59
|
+
|
52
60
|
def info
|
53
61
|
|
54
62
|
s = "MNIST-READY #{@@VERSION} (#{@@YEAR})\n"
|
@@ -92,15 +100,14 @@ class MnistDataset
|
|
92
100
|
|
93
101
|
def count_digits(hash)
|
94
102
|
count = {}
|
103
|
+
(0..9).each do |label|
|
104
|
+
count[label] = 0
|
105
|
+
end
|
95
106
|
hash.each do |digit|
|
96
|
-
|
97
|
-
|
98
|
-
count[label] = count[label] + 1
|
99
|
-
else
|
100
|
-
count[label] = 1
|
101
|
-
end
|
107
|
+
label = digit.label
|
108
|
+
count[label] = count[label] + 1
|
102
109
|
end
|
103
110
|
count
|
104
111
|
end
|
105
112
|
|
106
|
-
end
|
113
|
+
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.
|
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:
|
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.
|
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
|