Tensor(buffer)

Use base.batch_concat() to perform the concat operation on multiple tensor objects by batch. For details, see batch_concat(inputs).

Function Usage

Converts a NumPy array into a tensor.

The tensor data structure receives a buffer memory address passed as the parameter (buffer). Therefore, when using the NumPy array to pre-process data and convert the data into tensors, check whether the memory is modified during the pre-processing.

For example, transpose() is used to exchange the index values of arrays. However, this function does not rearrange the data memory addresses and returns the converted values only when obtaining the NumPy array. When the NumPy array is converted to tensors, the tensors are not rearranged. (That is, the NumPy array is an array after transpose() is performed, and tensors are an array before transpose() is performed.)

If you need to use functions that do not change the memory arrangement, such as transpose(), use APIs such as numpy.ascontiguousarray() to rearrange the memory data after transpose() is performed so that the converted tensor object data is consistent with the expected transposed array.

Input Parameter Description

Parameter

Type

Description

buffer

NumPy array

NumPy array to be converted into tensors

Output Parameter Description

Tensor object