Module: TensorStream::OpStub

Included in:
Ops
Defined in:
lib/tensor_stream/generated_stub/ops.rb

Instance Method Summary collapse

Instance Method Details

#add(input_a, input_b, name: nil) ⇒ Object

Returns x + y element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



18
19
20
21
# File 'lib/tensor_stream/generated_stub/ops.rb', line 18

def add(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:add, input_a, input_b, name: name)
end

#argmax(input_a, axis = nil, name: nil, dimension: nil, output_type: :int32) ⇒ Object

Returns the index with the largest value across axes of a tensor.

Options:

Parameters:

  • input_a

    tensor X (of type NUMERIC_TYPES)

  • axis (defaults to: nil)

    Describes which axis of the input tensor to reduce across. For vectors, use axis = 0 (of type INTEGER_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • dimension (Hash) (defaults to: nil)

    a customizable set of options

  • output_type (Hash) (defaults to: :int32)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (dimension:):

  • Same (Object)

    as axis

Options Hash (output_type:):

  • Output (Object)

    data type defaults to int32 default (:int32)

Returns:

  • Tensor



36
37
38
39
40
# File 'lib/tensor_stream/generated_stub/ops.rb', line 36

def argmax(input_a, axis = nil, name: nil, dimension: nil, output_type: :int32)
  check_allowed_types(input_a, TensorStream::Ops::NUMERIC_TYPES)
  check_allowed_types(axis, TensorStream::Ops::INTEGER_TYPES)
  _op(:argmax, input_a, axis, name: name, dimension: dimension, output_type: output_type)
end

#argmin(input_a, axis = nil, name: nil, dimension: nil, output_type: :int32) ⇒ Object

Returns the index with the smallest value across axes of a tensor.

Options:

Parameters:

  • input_a

    tensor X (of type NUMERIC_TYPES)

  • axis (defaults to: nil)

    Describes which axis of the input tensor to reduce across. For vectors, use axis = 0 (of type INTEGER_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • dimension (Hash) (defaults to: nil)

    a customizable set of options

  • output_type (Hash) (defaults to: :int32)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (dimension:):

  • Same (Object)

    as axis

Options Hash (output_type:):

  • Output (Object)

    data type defaults to int32 default (:int32)

Returns:

  • Tensor



55
56
57
58
59
# File 'lib/tensor_stream/generated_stub/ops.rb', line 55

def argmin(input_a, axis = nil, name: nil, dimension: nil, output_type: :int32)
  check_allowed_types(input_a, TensorStream::Ops::NUMERIC_TYPES)
  check_allowed_types(axis, TensorStream::Ops::INTEGER_TYPES)
  _op(:argmin, input_a, axis, name: name, dimension: dimension, output_type: output_type)
end

#ceil(input_a, name: nil) ⇒ Object

Returns element-wise smallest integer in not less than x

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



71
72
73
74
# File 'lib/tensor_stream/generated_stub/ops.rb', line 71

def ceil(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:ceil, input_a, name: name)
end

#cos(input_a, name: nil) ⇒ Object

Computes cos of input element-wise.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



86
87
88
89
# File 'lib/tensor_stream/generated_stub/ops.rb', line 86

def cos(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:cos, input_a, name: name)
end

#div(input_a, input_b, name: nil) ⇒ Object

Returns x / y element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



103
104
105
106
# File 'lib/tensor_stream/generated_stub/ops.rb', line 103

def div(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:div, input_a, input_b, name: name)
end

#equal(input_a, input_b, name: nil) ⇒ Object

Returns the truth value of (x == y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



120
121
122
123
# File 'lib/tensor_stream/generated_stub/ops.rb', line 120

def equal(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:equal, input_a, input_b, name: name)
end

#expand_dims(input, axis, name: nil) ⇒ Object

Inserts a dimension of 1 into a tensor’s shape. Given a tensor input, this operation inserts a dimension of 1 at the dimension index axis of input’s shape. The dimension index axis starts at zero; if you specify a negative number for axis it is counted backward from the end.

Options:

Parameters:

  • input

    A tensor

  • axis

    Specifies the dimension index at which to expand the shape of input. Must be in the range [-rank(input) - 1, rank(input)].

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



138
139
140
# File 'lib/tensor_stream/generated_stub/ops.rb', line 138

def expand_dims(input, axis, name: nil)
  _op(:expand_dims, input, axis, name: name)
end

#fill(dims, value, name: nil) ⇒ Object

This operation creates a tensor of shape dims and fills it with value.

Options:

Parameters:

  • dims

    tensor shape

  • value

    scalar value to fill with

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



153
154
155
# File 'lib/tensor_stream/generated_stub/ops.rb', line 153

def fill(dims, value, name: nil)
  _op(:fill, dims, value, name: name)
end

#floor(input_a, name: nil) ⇒ Object

Returns element-wise largest integer not greater than x.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



167
168
169
170
# File 'lib/tensor_stream/generated_stub/ops.rb', line 167

def floor(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:floor, input_a, name: name)
end

#floor_div(input_a, input_b, name: nil) ⇒ Object

Returns element-wise integer divistion.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



184
185
186
187
# File 'lib/tensor_stream/generated_stub/ops.rb', line 184

def floor_div(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:floor_div, input_a, input_b, name: name)
end

#greater(input_a, input_b, name: nil) ⇒ Object

Returns the truth value of (x > y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



201
202
203
204
# File 'lib/tensor_stream/generated_stub/ops.rb', line 201

def greater(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:greater, input_a, input_b, name: name)
end

#greater_equal(input_a, input_b, name: nil) ⇒ Object

Returns the truth value of (x >= y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



218
219
220
221
# File 'lib/tensor_stream/generated_stub/ops.rb', line 218

def greater_equal(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:greater_equal, input_a, input_b, name: name)
end

#less(input_a, input_b, name: nil) ⇒ Object

Returns the truth value of (x < y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



235
236
237
238
# File 'lib/tensor_stream/generated_stub/ops.rb', line 235

def less(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:less, input_a, input_b, name: name)
end

#less_equal(input_a, input_b, name: nil) ⇒ Object

Returns the truth value of (x <= y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



252
253
254
255
# File 'lib/tensor_stream/generated_stub/ops.rb', line 252

def less_equal(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:less_equal, input_a, input_b, name: name)
end

#log(input, name: nil) ⇒ Object

Computes natural logarithm of x element-wise.

Options:

Parameters:

  • input

    tensor X

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



267
268
269
# File 'lib/tensor_stream/generated_stub/ops.rb', line 267

def log(input, name: nil)
  _op(:log, input, name: name)
end

#mat_mul(input_a, input_b, transpose_a: false, transpose_b: false, name: nil) ⇒ Object Also known as: matmul

Multiplies matrix a by matrix b, producing a * b. The inputs must, following any transpositions, be tensors of rank 2 .

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • transpose_a (Hash) (defaults to: false)

    a customizable set of options

  • transpose_b (Hash) (defaults to: false)

    a customizable set of options

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (transpose_a:):

  • Transpose (Object)

    matrix A first default (false)

Options Hash (transpose_b:):

  • Transpose (Object)

    matrix B first default (false)

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



285
286
287
288
# File 'lib/tensor_stream/generated_stub/ops.rb', line 285

def mat_mul(input_a, input_b, transpose_a: false, transpose_b: false, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:mat_mul, input_a, input_b, transpose_a: transpose_a, transpose_b: transpose_b, name: name)
end

#max(input_a, input_b, name: nil) ⇒ Object

Returns the max of x and y (i.e. x > y ? x : y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X (of type NUMERIC_TYPES)

  • input_b

    tensor Y (of type NUMERIC_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



303
304
305
306
307
308
# File 'lib/tensor_stream/generated_stub/ops.rb', line 303

def max(input_a, input_b, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::NUMERIC_TYPES)
  check_allowed_types(input_b, TensorStream::Ops::NUMERIC_TYPES)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:max, input_a, input_b, name: name)
end

#min(input_a, input_b, name: nil) ⇒ Object

Returns the min of x and y (i.e. x < y ? x : y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X (of type NUMERIC_TYPES)

  • input_b

    tensor Y (of type NUMERIC_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



322
323
324
325
326
327
# File 'lib/tensor_stream/generated_stub/ops.rb', line 322

def min(input_a, input_b, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::NUMERIC_TYPES)
  check_allowed_types(input_b, TensorStream::Ops::NUMERIC_TYPES)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:min, input_a, input_b, name: name)
end

#mod(input_a, input_b, name: nil) ⇒ Object

Returns element-wise remainder of division.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



341
342
343
344
# File 'lib/tensor_stream/generated_stub/ops.rb', line 341

def mod(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:mod, input_a, input_b, name: name)
end

#mul(input_a, input_b, name: nil) ⇒ Object

Returns x * y element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



358
359
360
361
# File 'lib/tensor_stream/generated_stub/ops.rb', line 358

def mul(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:mul, input_a, input_b, name: name)
end

#negate(input, name: nil) ⇒ Object

Computes numerical negative value element-wise.

Options:

Parameters:

  • input

    tensor X

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



373
374
375
# File 'lib/tensor_stream/generated_stub/ops.rb', line 373

def negate(input, name: nil)
  _op(:negate, input, name: name)
end

#not_equal(input_a, input_b, name: nil) ⇒ Object

Returns the truth value of (x != y) element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



389
390
391
392
# File 'lib/tensor_stream/generated_stub/ops.rb', line 389

def not_equal(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:not_equal, input_a, input_b, name: name)
end

#ones_like(input, dtype: nil, name: nil) ⇒ Object

Creates a tensor with all elements set to 1. Given a single tensor (tensor), this operation returns a tensor of the same type and shape as tensor with all elements set to 1. Optionally, you can specify a new type (dtype) for the returned tensor.

Options:

Parameters:

  • input

    A tensor

  • dtype (Hash) (defaults to: nil)

    a customizable set of options

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (dtype:):

  • Optional (Object)

    new data type to cast into

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



408
409
410
# File 'lib/tensor_stream/generated_stub/ops.rb', line 408

def ones_like(input, dtype: nil, name: nil)
  _op(:ones_like, input, data_type: dtype, name: name)
end

#pow(input_a, input_b, name: nil) ⇒ Object

Computes the power of one value to another X^Y element wise

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



424
425
426
427
# File 'lib/tensor_stream/generated_stub/ops.rb', line 424

def pow(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:pow, input_a, input_b, name: name)
end

#prod(input_a, axis = nil, name: nil, keepdims: false) ⇒ Object Also known as: reduce_prod

Computes the product of elements across dimensions of a tensor. Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keepdims is true, the reduced dimensions are retained with length 1. If axis has no entries, all dimensions are reduced, and a tensor with a single element is returned.

Options:

Parameters:

  • input_a

    tensor X

  • axis (defaults to: nil)

    tensor X (of type INTEGER_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • keepdims (Hash) (defaults to: false)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (keepdims:):

  • If (Object)

    true, retains reduced dimensions with length 1. default (false)

Returns:

  • Tensor



445
446
447
448
449
450
451
# File 'lib/tensor_stream/generated_stub/ops.rb', line 445

def prod(input_a, axis = nil, name: nil, keepdims: false)
  check_allowed_types(axis, TensorStream::Ops::INTEGER_TYPES)
  input_a = TensorStream.convert_to_tensor(input_a)
  return input_a if input_a.shape.scalar?
  axis = cast_axis(input_a, axis)
  _op(:prod, input_a, axis, name: name, keepdims: keepdims)
end

#random_uniform(shape, name: nil, dtype: :float32, minval: 0, maxval: 1, seed: nil) ⇒ Object

Outputs random values from a uniform distribution.

Options:

Parameters:

  • shape

    A 1-D integer Tensor or array. The shape of the output tensor.

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • dtype (Hash) (defaults to: :float32)

    a customizable set of options

  • minval (Hash) (defaults to: 0)

    a customizable set of options

  • maxval (Hash) (defaults to: 1)

    a customizable set of options

  • seed (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (dtype:):

  • The (Object)

    type of the output: float16, float32, float64, int32, or int64 default (:float32)

Options Hash (minval:):

  • A (Object)

    0-D Tensor or ruby value of type dtype. The lower bound on the range of random values to generate. Defaults to 0. default (0)

Options Hash (maxval:):

  • A (Object)

    0-D Tensor or ruby value of type dtype. The upper bound on the range of random values to generate. Defaults to 1 if dtype is floating point. default (1)

Options Hash (seed:):

  • A (Object)

    ruby integer. Used to create a random seed for the distribution. See set_random_seed for behavior.

Returns:

  • Tensor



468
469
470
# File 'lib/tensor_stream/generated_stub/ops.rb', line 468

def random_uniform(shape, name: nil, dtype: :float32, minval: 0, maxval: 1, seed: nil)
  _op(:random_uniform, shape, name: name, dtype: dtype, minval: minval, maxval: maxval, seed: seed)
end

#range(start = 0, limit = 0, delta = 1, name: "range", dtype: nil, output_type: :int32) ⇒ Object

Creates a sequence of numbers. Creates a sequence of numbers that begins at start and extends by increments of delta up to but not including limit.

Options:

Parameters:

  • start (defaults to: 0)

    Acts as first entry in the range if limit is not nil; otherwise, acts as range limit and first entry defaults to 0.

  • limit (defaults to: 0)

    Upper limit of sequence, exclusive. If nil, defaults to the value of start while the first entry of the range defaults to 0.

  • delta (defaults to: 1)

    Number that increments start. Defaults to 1.

  • name (Hash) (defaults to: "range")

    a customizable set of options

  • dtype (Hash) (defaults to: nil)

    a customizable set of options

  • output_type (Hash) (defaults to: :int32)

    a customizable set of options

Options Hash (name:):

  • A (Object)

    name for the operation. Defaults to “range”. default (“range”)

Options Hash (dtype:):

  • The (Object)

    type of the elements of the resulting tensor.

Options Hash (output_type:):

  • Output (Object)

    data type defaults to int32 default (:int32)

Returns:

  • Tensor



487
488
489
# File 'lib/tensor_stream/generated_stub/ops.rb', line 487

def range(start = 0, limit = 0, delta = 1, name: "range", dtype: nil, output_type: :int32)
  _op(:range, start, limit, delta, name: name, dtype: dtype, output_type: output_type)
end

#rank(input, name: nil) ⇒ Object

Returns the rank of a tensor

Options:

Parameters:

  • input

    A tensor

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



501
502
503
504
505
# File 'lib/tensor_stream/generated_stub/ops.rb', line 501

def rank(input, name: nil)
  input = convert_to_tensor(input)
  return cons(input.shape.ndims) if input.shape.known?
  _op(:rank, input, name: name)
end

#reshape(input, shape, name: nil) ⇒ Object

Reshapes a tensor. Given tensor, this operation returns a tensor that has the same values as tensor with shape shape.

Options:

Parameters:

  • input

    A tensor

  • shape

    A new tensor shape

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



519
520
521
# File 'lib/tensor_stream/generated_stub/ops.rb', line 519

def reshape(input, shape, name: nil)
  _op(:reshape, input, shape, name: name)
end

#round(input_a, name: nil) ⇒ Object

Rounds the values of a tensor to the nearest integer, element-wise

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



533
534
535
536
# File 'lib/tensor_stream/generated_stub/ops.rb', line 533

def round(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:round, input_a, name: name)
end

#rsqrt(input_a, name: nil) ⇒ Object

Computes reciprocal of square root of x element-wise.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



548
549
550
551
# File 'lib/tensor_stream/generated_stub/ops.rb', line 548

def rsqrt(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:rsqrt, input_a, name: name)
end

#shape(input, name: nil, out_type: :int32) ⇒ Object

This operation returns a 1-D integer tensor representing the shape of input

Options:

Parameters:

  • input

    A tensor

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • out_type (Hash) (defaults to: :int32)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (out_type:):

  • Optional (Object)

    output type default (:int32)

Returns:

  • Tensor



564
565
566
567
568
# File 'lib/tensor_stream/generated_stub/ops.rb', line 564

def shape(input, name: nil, out_type: :int32)
  return constant(shape_eval(input, out_type), dtype: out_type, name: "Shape/#{name}") if input.is_a?(Array) && !input[0].is_a?(Tensor)
  return constant(input.shape.shape, dtype: out_type, name: "Shape/#{input.name}_c") if shape_full_specified(input)
  _op(:shape, input, name: name, out_type: out_type)
end

#sigmoid(input_a, name: nil) ⇒ Object

Computes sigmoid of x element-wise.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



580
581
582
583
# File 'lib/tensor_stream/generated_stub/ops.rb', line 580

def sigmoid(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:sigmoid, input_a, name: name)
end

#sign(input_a, name: nil) ⇒ Object

Computes sign of input element-wise. y = sign(x) = -1 if x < 0; 0 if x == 0 or tf.is_nan(x); 1 if x > 0. Zero is returned for NaN inputs.

Options:

Parameters:

  • input_a

    tensor X

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



597
598
599
# File 'lib/tensor_stream/generated_stub/ops.rb', line 597

def sign(input_a, name: nil)
  _op(:sign, input_a, name: name)
end

#sin(input_a, name: nil) ⇒ Object

Computes sin of input element-wise.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



611
612
613
614
# File 'lib/tensor_stream/generated_stub/ops.rb', line 611

def sin(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:sin, input_a, name: name)
end

#size(input, name: nil, out_type: :int32) ⇒ Object

Returns the size of a tensor. Returns a 0-D Tensor representing the number of elements in input of type out_type. Defaults to :int32.

Options:

Parameters:

  • input

    A tensor

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • out_type (Hash) (defaults to: :int32)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (out_type:):

  • Optional (Object)

    output type default (:int32)

Returns:

  • Tensor



628
629
630
# File 'lib/tensor_stream/generated_stub/ops.rb', line 628

def size(input, name: nil, out_type: :int32)
  _op(:size, input, name: name, out_type: out_type)
end

#strided_slice(input, _begin, _end, strides = nil, name: nil) ⇒ Object

Extracts a strided slice of a tensor this op extracts a slice of size ‘(end-begin)/stride`

from the given `input_` tensor. Starting at the location specified by `begin`
the slice continues by adding `stride` to the index until all dimensions are
not less than `end`.
Note that a stride can be negative, which causes a reverse slice.

Options:

Parameters:

  • input

    A tensor

  • _begin

    start index

  • _end

    end index

  • strides (defaults to: nil)

    end index

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



650
651
652
# File 'lib/tensor_stream/generated_stub/ops.rb', line 650

def strided_slice(input, _begin, _end, strides = nil, name: nil)
  _op(:strided_slice, input, _begin, _end, strides, name: name)
end

#sub(input_a, input_b, name: nil) ⇒ Object Also known as: subtract

Returns x - y element-wise.

This operation supports broadcasting

Options:

Parameters:

  • input_a

    tensor X

  • input_b

    tensor Y

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



666
667
668
669
# File 'lib/tensor_stream/generated_stub/ops.rb', line 666

def sub(input_a, input_b, name: nil)
  input_a, input_b = apply_data_type_coercion(input_a, input_b)
  _op(:sub, input_a, input_b, name: name)
end

#sum(input_a, axis_p = nil, axis: nil, name: nil, keepdims: false) ⇒ Object Also known as: reduce_sum

Computes the sum of elements across dimensions of a tensor. Reduces input_tensor along the dimensions given in axis. Unless keepdims is true, the rank of the tensor is reduced by 1 for each entry in axis. If keepdims is true, the reduced dimensions are retained with length 1. If axis has no entries, all dimensions are reduced, and a tensor with a single element is returned.

Options:

Parameters:

  • input_a

    tensor X

  • axis_p (defaults to: nil)

    tensor X (of type INTEGER_TYPES)

  • axis (Hash) (defaults to: nil)

    a customizable set of options

  • name (Hash) (defaults to: nil)

    a customizable set of options

  • keepdims (Hash) (defaults to: false)

    a customizable set of options

Options Hash (axis:):

  • axis (Object)

Options Hash (name:):

  • Optional (Object)

    name

Options Hash (keepdims:):

  • If (Object)

    true, retains reduced dimensions with length 1. default (false)

Returns:

  • Tensor



689
690
691
692
693
694
695
696
# File 'lib/tensor_stream/generated_stub/ops.rb', line 689

def sum(input_a, axis_p = nil, axis: nil, name: nil, keepdims: false)
  check_allowed_types(axis_p, TensorStream::Ops::INTEGER_TYPES)
  input_a = TensorStream.convert_to_tensor(input_a)
  return input_a if input_a.shape.scalar?
  axis_p = axis_p || axis
  axis_p = cast_axis(input_a, axis_p)
  _op(:sum, input_a, axis_p, name: name, keepdims: keepdims)
end

#tan(input_a, name: nil) ⇒ Object

Computes tan of input element-wise.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



709
710
711
712
# File 'lib/tensor_stream/generated_stub/ops.rb', line 709

def tan(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:tan, input_a, name: name)
end

#tanh(input_a, name: nil) ⇒ Object

Computes tanh of input element-wise.

Options:

Parameters:

  • input_a

    tensor X (of type FLOATING_POINT_TYPES)

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



724
725
726
727
# File 'lib/tensor_stream/generated_stub/ops.rb', line 724

def tanh(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:tanh, input_a, name: name)
end

#tile(input, multiples, name: nil) ⇒ Object

Constructs a tensor by tiling a given tensor. This operation creates a new tensor by replicating input multiples times. The output tensor’s i’th dimension has input.dims(i) * multiples elements, and the values of input are replicated multiples times along the ‘i’th dimension. For example, tiling [a b c d] by [2] produces [a b c d a b c d].

Options:

Parameters:

  • input

    A tensor

  • multiples

    Must be one of the following types: int32, int64. 1-D. Length must be the same as the number of dimensions in input

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



743
744
745
# File 'lib/tensor_stream/generated_stub/ops.rb', line 743

def tile(input, multiples, name: nil)
  _op(:tile, input, multiples, name: name)
end

#top_k(input, k = 1, sorted: true, name: nil) ⇒ Object

Finds values and indices of the ‘k` largest entries for the last dimension.

Options:

Parameters:

  • input

    1-D or higher ‘Tensor` with last dimension at least `k`.

  • k (defaults to: 1)

    0-D ‘int32` `Tensor`. Number of top elements to look for along the last dimension (along each row for matrices)

  • sorted (Hash) (defaults to: true)

    a customizable set of options

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (sorted:):

  • If (Object)

    true the resulting ‘k` elements will be sorted by the values in descending order. default (true)

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



759
760
761
762
# File 'lib/tensor_stream/generated_stub/ops.rb', line 759

def top_k(input, k = 1, sorted: true, name: nil)
  result = _op(:top_k, input, k, sorted: sorted, name: name)
  [result[0], result[1]]
end

#zeros(shape, dtype: :float32, name: nil) ⇒ Object

Creates a tensor with all elements set to zero

Options:

Parameters:

  • shape

    A 1-D integer Tensor or ruby array. The shape of the output tensor.

  • dtype (Hash) (defaults to: :float32)

    a customizable set of options

  • name (Hash) (defaults to: nil)

    a customizable set of options

Options Hash (dtype:):

  • Optional (Object)

    name default (:float32)

Options Hash (name:):

  • Optional (Object)

    name

Returns:

  • Tensor



775
776
777
# File 'lib/tensor_stream/generated_stub/ops.rb', line 775

def zeros(shape, dtype: :float32, name: nil)
  _op(:zeros, shape, dtype: dtype, name: name)
end