mnist-ready 1.0.1 → 1.1.1

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
  SHA256:
3
- metadata.gz: 3b8f7fc1f5a021b575c6d8db4b572ff07f35b7cf38970a01f71c7f1b6b7a7b29
4
- data.tar.gz: bab03e221396b4665c22b9572a4ecaa7e083490618918141bb5d06560123318a
3
+ metadata.gz: 4b2b0059fb779cef3b208d6b061f44cf0276050bf2ab03c7ba35d26433bdb119
4
+ data.tar.gz: 964e0569bd60637da0c376d054358a9ed70512942f238231050533a1028dab40
5
5
  SHA512:
6
- metadata.gz: 7cba8a705e4d7fd003dca541b636627c512dc30213878cdc4b696a8f8e1b2335ec02661015695844a36a8040df02858e088fb2f9e0da9cf4eb9dc0ee3658d8f8
7
- data.tar.gz: 44f2bf8a067de706b647532e4a1fcd5c113aaff6888e9893cefc9064ffabcf815cc2673ab650fde97443bc32ff9d6daf4a2f2f6768f9e3e11153b435705db190
6
+ metadata.gz: bf6e5fda8c12fb6dac08c923db72c32b3948bfeb432c03310f88dd711a54d85b847a4c124b5d1787f98f115ff7186601b0c2472cd37c8a5fdbca3e1fc8ae8bab
7
+ data.tar.gz: 3622880f3bafe45b3b621221ebfa9c3f02459c9a76551898c38efdef3087cb1cc74b411bf0889e76b3f4081c01a95d2c714c73ebf52ea5eac1c96128fbf57904
data/lib/mnist-ready.rb CHANGED
@@ -2,7 +2,7 @@ require_relative 'mnist_dataset.rb'
2
2
 
3
3
  =begin
4
4
 
5
- MNIST = MnistDataset.instance
5
+ MNIST = MnistDataset.instance(show_progress = true)
6
6
 
7
7
  # 70,000 digits in total
8
8
  puts MNIST.all_set.size # => 70000
data/lib/mnist_dataset.rb CHANGED
@@ -4,14 +4,14 @@ require 'json'
4
4
 
5
5
  class MnistDataset
6
6
 
7
- @@VERSION = "1.0.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
14
+ def initialize(show_progress)
15
15
  test_set = File.join(File.dirname(__FILE__), '..', 'data', 'mnist_test.csv')
16
16
 
17
17
  @train_set = []
@@ -23,6 +23,7 @@ class MnistDataset
23
23
  digit = MnistDigit.new(label, pixels)
24
24
  @test_set.push(digit)
25
25
  @all_set.push(digit)
26
+ print "\r#{all_set.size}" if show_progress
26
27
  end
27
28
 
28
29
  (1..3).each do |index|
@@ -32,21 +33,27 @@ class MnistDataset
32
33
  digit = MnistDigit.new(label, pixels)
33
34
  @train_set.push(digit)
34
35
  @all_set.push(digit)
36
+ print "\r#{all_set.size}" if show_progress
35
37
  end
36
38
  end
37
-
39
+ puts if show_progress
38
40
  end
39
41
 
40
42
  attr_reader :all_set, :train_set, :test_set
41
43
 
42
- def self.instance
44
+ def self.instance(show_progress = false)
43
45
  return @instance if @instance
44
46
  @instance_mutex.synchronize do
45
- @instance ||= new
47
+ @instance ||= new(show_progress)
46
48
  end
47
49
  @instance
48
50
  end
49
51
 
52
+ # very important to override this otherwise inspect will go crazy trying to inspect 70000 elements
53
+ def inspect
54
+ to_s
55
+ end
56
+
50
57
  def info
51
58
 
52
59
  s = "MNIST-READY #{@@VERSION} (#{@@YEAR})\n"
@@ -101,4 +108,4 @@ class MnistDataset
101
108
  count
102
109
  end
103
110
 
104
- end
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.0.1
4
+ version: 1.1.1
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-01 00:00:00.000000000 Z
11
+ date: 2023-03-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: sergio.oliveira.jr@gmail.com