Method: CIFAR10.load_test

Defined in:
lib/nn/cifar10.rb

.load_testObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/nn/cifar10.rb', line 22

def self.load_test
  if File.exist?("CIFAR-10-test.marshal")
    marshal = File.binread("CIFAR-10-test.marshal")
    return Marshal.load(marshal)
  end
  bin = File.binread("#{dir}/test_batch.bin")
  datasets = bin.unpack("C*")
  x_test = []
  y_test = []
  loop do
    label = datasets.shift
    break unless label
    x_test << datasets.slice!(0, 3072)
    y_test << label
  end
  test = [x_test, y_test]
  File.binwrite("CIFAR-10-test.marshal", Marshal.dump(test))
  test
end