module Tensorflow::Ops

Public Class Methods

broadcast_mul(vector, matrix) click to toggle source
# File lib/tensorflow/ops/gradients.rb, line 3
def self.broadcast_mul(vector, matrix)
  vector = Tensorflow.expand_dims(vector, -1)
  vector * matrix
end

Public Instance Methods

cast(x, destination_dtype, source_dtype: nil, truncate: false) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 4
def cast(x, destination_dtype, source_dtype: nil, truncate: false)
  RawOps.cast(x, srct: source_dtype, dstt: destination_dtype, truncate: truncate)
end
constant(value, dtype: nil, shape: [], name: 'Const') click to toggle source
# File lib/tensorflow/ops/ops.rb, line 8
def constant(value, dtype: nil, shape: [], name: 'Const')
  tensor = value.is_a?(Tensor) ? value : Tensor.new(value, dtype: dtype, shape: shape)
  RawOps.const(value: tensor, dtype: tensor.dtype, name: name)
end
expand_dims(input, axis) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 13
def expand_dims(input, axis)
  RawOps.expand_dims(input, axis)
end
fill(dims, value, dtype: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 17
def fill(dims, value, dtype: nil)
  RawOps.fill(dims, value, typeT: dtype)
end
identity(input) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 21
def identity(input)
  RawOps.identity(input)
end
ones(dims, dtype: :float) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 25
def ones(dims, dtype: :float)
  fill(dims, 1, dtype: dtype)
end
pack(values, n: nil, typeT: nil, axis: 0) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 29
def pack(values, n: nil, typeT: nil, axis: 0)
  typeT ||= TensorData.figure_dtype(values)
  n ||= values.count
  RawOps.pack(values, n: n, typeT: typeT, axis: axis)
end
placeholder(dtype, name: 'Placeholder', shape: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 35
def placeholder(dtype, name: 'Placeholder', shape: nil)
  RawOps.placeholder(dtype: dtype, shape: shape, name: name)
end
prevent_gradient(input, typeT: nil, message: "") click to toggle source
# File lib/tensorflow/ops/ops.rb, line 39
def prevent_gradient(input, typeT: nil, message: "")
  RawOps.prevent_gradient(input, typeT: typeT, message: message, name: "PreventGradient")
end
range(start, limit = nil, delta = 1) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 47
def range(start, limit = nil, delta = 1)
  unless limit
    limit = start
    start = 0
  end
  RawOps.range(start, limit, delta)
end
rank(input, typeT: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 43
def rank(input, typeT: nil)
  RawOps.rank(input, typeT: typeT)
end
reshape(tensor, shape) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 55
def reshape(tensor, shape)
  RawOps.reshape(tensor, shape, typeT: tensor.output_types.first)
end
shape(input, out_type) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 59
def shape(input, out_type)
  RawOps.shape(input, out_type: out_type)
end
split(value, split_dim, num_split: nil, typeT: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 63
def split(value, split_dim, num_split: nil, typeT: nil)
  RawOps.split(split_dim, value, num_split: num_split, typeT: typeT)
end
split_v(value, size_splits, split_dim=0, num_split: nil, typeT: nil, tlen: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 67
def split_v(value, size_splits, split_dim=0, num_split: nil, typeT: nil, tlen: nil)
  num_split ||= size_splits.length
  RawOps.split_v(value, size_splits, split_dim, num_split: num_split, typeT: typeT, tlen: tlen)
end
squeeze(input, axis: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 72
def squeeze(input, axis: nil)
  RawOps.squeeze(input, squeeze_dims: axis)
end
timestamp() click to toggle source
# File lib/tensorflow/ops/ops.rb, line 76
def timestamp
  RawOps.timestamp
end
transpose(x, perm: [1, 0]) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 80
def transpose(x, perm: [1, 0])
  RawOps.transpose(x, perm)
end
where(condition, x: nil, y: nil) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 84
def where(condition, x: nil, y: nil)
  if x.nil? && y.nil?
    RawOps.where(condition)
  elsif x && y
    RawOps.select_v2(condition, x, y)
  else
    raise(Error::InvalidArgumentError, "x and y must both be non nil or both be nil")
  end
end
zeros(dims, dtype: :float) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 94
def zeros(dims, dtype: :float)
  fill(dims, 0, dtype: dtype)
end
zeros_like(x) click to toggle source
# File lib/tensorflow/ops/ops.rb, line 98
def zeros_like(x)
  RawOps.zeros_like(x)
end