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