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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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.

Params:

input_a

tensor X (of type NUMERIC_TYPES)

axis

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

Options:

:name

Optional name

:dimension

Same as axis

:output_type

Output data type defaults to int32 default (:int32)



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.

Params:

input_a

tensor X (of type NUMERIC_TYPES)

axis

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

Options:

:name

Optional name

:dimension

Same as axis

:output_type

Output data type defaults to int32 default (:int32)



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

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



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.

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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.

Params:

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)].

Options:

:name

Optional name



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.

Params:

dims

tensor shape

value

scalar value to fill with

Options:

:name

Optional name



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.

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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_equal(input_a, input_b, name: nil) ⇒ Object

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

This operation supports broadcasting

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

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.

Params:

input

tensor X

Options:

:name

Optional name



250
251
252
# File 'lib/tensor_stream/generated_stub/ops.rb', line 250

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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:transpose_a

Transpose matrix A first default (false)

:transpose_b

Transpose matrix B first default (false)

:name

Optional name



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

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

Params:

input_a

tensor X (of type NUMERIC_TYPES)

input_b

tensor Y (of type NUMERIC_TYPES)

Options:

:name

Optional name



286
287
288
289
290
291
# File 'lib/tensor_stream/generated_stub/ops.rb', line 286

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

Params:

input_a

tensor X (of type NUMERIC_TYPES)

input_b

tensor Y (of type NUMERIC_TYPES)

Options:

:name

Optional name



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

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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

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.

Params:

input

tensor X

Options:

:name

Optional name



356
357
358
# File 'lib/tensor_stream/generated_stub/ops.rb', line 356

def negate(input, name: nil)
  _op(:negate, input, 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.

Params:

input

A tensor

Options:

:dtype

Optional new data type to cast into

:name

Optional name



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

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

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

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.

Params:

input_a

tensor X

axis

tensor X (of type INTEGER_TYPES)

Options:

:name

Optional name

:keepdims

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



411
412
413
414
415
416
417
# File 'lib/tensor_stream/generated_stub/ops.rb', line 411

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.

Params:

shape

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

Options:

:name

Optional name

:dtype

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

:minval

A 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)

:maxval

A 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)

:seed

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



434
435
436
# File 'lib/tensor_stream/generated_stub/ops.rb', line 434

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.

Params:

start

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

limit

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

delta

Number that increments start. Defaults to 1.

Options:

:name

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

:dtype

The type of the elements of the resulting tensor.

:output_type

Output data type defaults to int32 default (:int32)



453
454
455
# File 'lib/tensor_stream/generated_stub/ops.rb', line 453

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

Params:

input

A tensor

Options:

:name

Optional name



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

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.

Params:

input

A tensor

shape

A new tensor shape

Options:

:name

Optional name



485
486
487
# File 'lib/tensor_stream/generated_stub/ops.rb', line 485

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

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



499
500
501
502
# File 'lib/tensor_stream/generated_stub/ops.rb', line 499

def round(input_a, name: nil)
  check_allowed_types(input_a, TensorStream::Ops::FLOATING_POINT_TYPES)
  _op(:round, 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

Params:

input

A tensor

Options:

:name

Optional name

:out_type

Optional output type default (:int32)



515
516
517
518
519
# File 'lib/tensor_stream/generated_stub/ops.rb', line 515

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.

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



531
532
533
534
# File 'lib/tensor_stream/generated_stub/ops.rb', line 531

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.

Params:

input_a

tensor X

Options:

:name

Optional name



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

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.

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



562
563
564
565
# File 'lib/tensor_stream/generated_stub/ops.rb', line 562

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.

Params:

input

A tensor

Options:

:name

Optional name

:out_type

Optional output type default (:int32)



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

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

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

Returns x - y element-wise.

This operation supports broadcasting

Params:

input_a

tensor X

input_b

tensor Y

Options:

:name

Optional name



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

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 = 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.

Params:

input_a

tensor X

axis

tensor X (of type INTEGER_TYPES)

Options:

:name

Optional name

:keepdims

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



617
618
619
620
621
622
623
# File 'lib/tensor_stream/generated_stub/ops.rb', line 617

def sum(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(:sum, input_a, axis, name: name, keepdims: keepdims)
end

#tan(input_a, name: nil) ⇒ Object

Computes tan of input element-wise.

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



636
637
638
639
# File 'lib/tensor_stream/generated_stub/ops.rb', line 636

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.

Params:

input_a

tensor X (of type FLOATING_POINT_TYPES)

Options:

:name

Optional name



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

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].

Params:

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

Options:

:name

Optional name



670
671
672
# File 'lib/tensor_stream/generated_stub/ops.rb', line 670

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

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

Creates a tensor with all elements set to zero

Params:

shape

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

Options:

:dtype

Optional name default (:float32)

:name

Optional name



685
686
687
# File 'lib/tensor_stream/generated_stub/ops.rb', line 685

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