bittensor.tensor
#
Module Contents#
Classes#
Represents a Tensor object. |
|
Functions#
|
Casts the raw value to a string representing the torch data type. |
|
Casts the raw value to a string representing the tensor shape. |
Attributes#
- bittensor.tensor.TORCH_DTYPES#
- class bittensor.tensor.Tensor(**data)#
Bases:
pydantic.BaseModel
Represents a Tensor object.
- Parameters:
- _extract_dtype#
- _extract_shape#
- deserialize()#
Deserializes the Tensor object.
- Returns:
The deserialized tensor object.
- Return type:
- Raises:
Exception – If the deserialization process encounters an error.
- numpy()#
- Return type:
numpy.ndarray
- static serialize(tensor)#
Serializes the given tensor.
- Parameters:
tensor (torch.Tensor) – The tensor to serialize.
- Returns:
The serialized tensor.
- Return type:
- Raises:
Exception – If the serialization process encounters an error.
- tensor()#
- Return type:
- bittensor.tensor.cast_dtype(raw)#
Casts the raw value to a string representing the torch data type.
- Parameters:
raw (Union[None, torch.dtype, str]) – The raw value to cast.
- Returns:
The string representing the torch data type.
- Return type:
- Raises:
Exception – If the raw value is of an invalid type.
- bittensor.tensor.cast_shape(raw)#
Casts the raw value to a string representing the tensor shape.
- class bittensor.tensor.tensor#