class Treyja::Reader
Constants
- MAGIC_BYTES
Public Class Methods
new(file = nil)
click to toggle source
# File lib/treyja/reader.rb, line 12 def initialize file = nil io = file ? open(file) : STDIN io.binmode @enumerator = Enumerator.new do |y| while magic = io.read(4) raise "Incorrect magic bytes" unless magic == MAGIC_BYTES length = io.read(8).reverse.unpack("Q").first.to_i y << Tensors::TensorsProto.decode(io.read(length)) end end end