k_matrix: Cast to a TensorFlow matrix

View source: R/tf_util.R

k_matrixR Documentation

Cast to a TensorFlow matrix

Description

Cast to a TensorFlow matrix

Usage

k_matrix(x, dtype = NULL)

Arguments

x

Numeric object to be converted to a matrix Tensor.

dtype

Type of the elements of the resulting tensor. Defaults to keras3::config_floatx().

Value

A two-dimensional tf.Tensor with values from x. The shape will be ⁠(nrow(x), ncol(x))⁠ where x is first converted to an R matrix via as.matrix().

Examples

if (interactive()) {
  k_matrix(diag(1:3))
  k_matrix(diag(1:3), dtype = "int32")
  # Vectors are converted to columns:
  k_matrix(1:3)
}


reservr documentation built on June 24, 2024, 5:10 p.m.