Tensor
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
Function Description
Defines the Tensor constructor.
Prototype
1 | Tensor(data, *, tensor_desc: TensorDesc=None) |
Parameters
Parameter |
Data Type |
Description |
|---|---|---|
data |
Any |
Tensor data, which can be a Python list or a NumPy array. |
tensor_desc |
TensorDesc |
Tensor description. When this parameter is specified, if the dtype of the input data is different from that of tensor_desc, the system attempts to forcibly convert the data to the dtype of tensor_desc. If the shape of the input data is different from that of tensor_desc, an error is reported. |
Returns
None is returned in normal scenarios.
A DfException is thrown upon exceptions. You can catch DfException and retrieve its error_code and message attributes to check the specific error code and error details. For details, see DataFlow Error Codes.
Examples
1 2 3 | tensor = Tensor([1]) tensor = Tensor(numpy.array([1])) tensor = Tensor([1], tensor_desc=TensorDesc(dataflow.DT_FLOAT, [1])) |
Constraints
None