Sha256: 2430f943519303ee681146bdf2bcea1531f56367848b6bf05704cb9f11d88fc4

Contents?: true

Size: 533 Bytes

Versions: 8

Compression:

Stored size: 533 Bytes

Contents

#!/usr/bin/env ruby

require "bundler/setup"
require "tensor_stream"
require 'mnist-learn'
require 'fileutils'

mnist = Mnist.read_data_sets('/tmp/data', one_hot: true)

ts = TensorStream
test_data = mnist.test.images
FileUtils.mkdir_p 'test_images'

sess = ts.session

test_data.each_with_index do |image , index|
  image = 255.t - ts.cast(ts.reshape(image, [28, 28, 1]), :uint8) # reshape image
  encoder = ts.image.encode_png(image)
  blob = sess.run(encoder)
  File.write(File.join('test_images', "#{index}_image.png"), blob)
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tensor_stream-opencl-0.3.2 samples/dump_mnist.rb
tensor_stream-opencl-0.3.1 samples/dump_mnist.rb
tensor_stream-opencl-0.3.0 samples/dump_mnist.rb
tensor_stream-opencl-0.2.10 samples/dump_mnist.rb
tensor_stream-opencl-0.2.9 samples/dump_mnist.rb
tensor_stream-opencl-0.2.8 samples/dump_mnist.rb
tensor_stream-opencl-0.2.6 samples/dump_mnist.rb
tensor_stream-opencl-0.2.5 samples/dump_mnist.rb