module TensorStream::TensorMixins
Public Instance Methods
!=(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 77 def !=(other) _op(:not_equal, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
%(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 40 def %(other) TensorStream.mod(self, other) end
*(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 20 def *(other) _op(:mul, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
**(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 24 def **(other) _op(:pow, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
+(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 3 def +(other) _op(:add, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
-(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 32 def -(other) _op(:sub, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
-@()
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 36 def -@ _op(:negate, self) end
/(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 28 def /(other) _op(:div, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
<(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 73 def <(other) _op(:less, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
<=(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 89 def <=(other) _op(:less_equal, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
==(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 68 def ==(other) TensorStream.check_data_types(self, other) _op(:equal, self, other) end
>(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 81 def >(other) _op(:greater, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
>=(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 85 def >=(other) _op(:greater_equal, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
[](index)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 7 def [](index) if index.is_a?(Range) last = if index.end.nil? [TensorStream.shape(self)[0]] else [index.max + 1] end _op(:strided_slice, self, [index.min], last, [1]) else _op(:index, self, index) end end
and(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 93 def and(other) _op(:logical_and, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
cast(data_type = :float32, name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 105 def cast(data_type = :float32, name: nil) TensorStream.cast(self, data_type, name: name) end
ceil(name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 48 def ceil(name: nil) TensorStream.ceil(self, name: name) end
dot(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 101 def dot(other) _op(:mat_mul, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
floor(name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 44 def floor(name: nil) TensorStream.floor(self, name: name) end
log(name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 56 def log(name: nil) TensorStream.log(self, name: name) end
matmul(other)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 97 def matmul(other) _op(:mat_mul, self, TensorStream.convert_to_tensor(other, dtype: data_type)) end
reduce(op_type = :+, axis: nil, keepdims: false, name: nil)
click to toggle source
Apply a reduction to tensor
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 115 def reduce(op_type = :+, axis: nil, keepdims: false, name: nil) reduce_op = case op_type.to_sym when :+ :sum when :* :prod when :mean :mean else raise "unsupported reduce op type #{op_type} valid values are :+, :*, :prod, :mean" end raise "blocks are not supported for tensors" if block_given? TensorStream.reduce(reduce_op, self, axis, keepdims: keepdims, name: name) end
reshape(shape, name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 60 def reshape(shape, name: nil) TensorStream.reshape(self, shape, name: name) end
round(name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 52 def round(name: nil) TensorStream.round(self, name: name) end
var(name: nil)
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 109 def var(name: nil) TensorStream.variable(self, name: name) end
zero?()
click to toggle source
# File lib/tensor_stream/helpers/tensor_mixins.rb, line 64 def zero? _op(:equal, self, TensorStream.constant(0, dtype: data_type, name: "equal/is_zero?")) end