Learn R Programming

RBERT (version 0.1.11)

assert_rank: Confirm the rank of a tensor

Description

Throws an error if the tensor rank is not of the expected rank.

Usage

assert_rank(tensor, expected_rank, name = NULL)

Arguments

tensor

A tf.Tensor to check the rank of.

expected_rank

Integer vector or list of integers, expected rank.

name

Optional name of the tensor for the error message.

Value

TRUE if the Tensor is of the expected rank (error otherwise).

Examples

Run this code
# NOT RUN {
with(tensorflow::tf$variable_scope("examples",
  reuse = tensorflow::tf$AUTO_REUSE
), {
  ids <- tensorflow::tf$get_variable("x", dtype = "int32", shape = 10L)
  assert_rank(ids, 1)
  assert_rank(ids, 1:2)
  assert_rank(ids, 2)
})
# }

Run the code above in your browser using DataLab