Learn R Programming

torch (version 0.0.2)

torch_trace: Trace

Description

Trace

Arguments

trace(input) -> Tensor

Returns the sum of the elements of the diagonal of the input 2-D matrix.

Examples

Run this code
# NOT RUN {
if (torch_is_installed()) {

x = torch_arange(1., 10.)$view(c(3, 3))
x
torch_trace(x)
}
# }

Run the code above in your browser using DataLab