Class: Rbmnist::MNIST::Test
- Inherits:
-
Object
- Object
- Rbmnist::MNIST::Test
- Extended by:
- Unzippable
- Defined in:
- lib/rbmnist/mnist.rb
Constant Summary collapse
- IMAGE_COUNT =
10000- CLEAN_IMAGE_COUNT =
5000- @@images =
[]
- @@labels =
[]
Class Method Summary collapse
Methods included from Unzippable
Class Method Details
.clean_images ⇒ Object
44 45 46 |
# File 'lib/rbmnist/mnist.rb', line 44 def self.clean_images images[0...CLEAN_IMAGE_COUNT] end |
.clean_labels ⇒ Object
48 49 50 |
# File 'lib/rbmnist/mnist.rb', line 48 def self.clean_labels labels[0...CLEAN_IMAGE_COUNT] end |
.images ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rbmnist/mnist.rb', line 33 def self.images if @@images.length == 0 img_bytes = unzip_from_path(__dir__ + '/../../data/t10k-images-idx3-ubyte.gz') curr_byte = 16 @@images = Array.new(IMAGE_COUNT) do |pic| Rbmnist::ImageWrapper.new(img_bytes[curr_byte...(curr_byte += 784)]) end end @@images end |
.labels ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rbmnist/mnist.rb', line 52 def self.labels if @@labels.length == 0 label_bytes = unzip_from_path(__dir__ + '/../../data/t10k-labels-idx1-ubyte.gz') curr_byte = 8 @@labels = Array.new(IMAGE_COUNT) do |label| label_bytes[curr_byte...(curr_byte += 1)].first end end @@labels end |