lib/torch/inspector.rb in torch-rb-0.1.2 vs lib/torch/inspector.rb in torch-rb-0.1.3
- old
+ new
@@ -1,15 +1,18 @@
module Torch
module Inspector
# TODO make more performance, especially when summarizing
+ # how? only read data that will be displayed
def inspect
data =
if numel == 0
"[]"
elsif dim == 0
- to_a.first
+ item
else
+ summarize = numel > 1000
+
values = to_a.flatten
abs = values.select { |v| v != 0 }.map(&:abs)
max = abs.max || 1
min = abs.min || 1
@@ -33,11 +36,9 @@
end
else
total += max.to_s.size
fmt = "%#{total}d"
end
-
- summarize = numel > 1000
inspect_level(to_a, fmt, dim - 1, 0, summarize)
end
attributes = []