torch_geometric.data.FeatureStore
- class FeatureStore(tensor_attr_cls: Optional[Any] = None)[source]
基础类:
ABC一个抽象基类,用于从远程特征存储中访问特征。
- Parameters:
tensor_attr_cls (TensorAttr, 可选) – 用户定义的
TensorAttr类,用于自定义所需的属性及其顺序,以唯一标识张量值。 (默认:None)
- put_tensor(tensor: Union[Tensor, ndarray], *args, **kwargs) bool[source]
Synchronously adds a
tensorto theFeatureStore. Returns whether insertion was successful.- Parameters:
tensor (torch.Tensor or np.ndarray) – The feature tensor to be added.
*args – Arguments passed to
TensorAttr.**kwargs – Keyword arguments passed to
TensorAttr.
- Raises:
ValueError – If the input
TensorAttris not fully specified.- Return type:
bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。
- get_tensor(*args, convert_type: bool = False, **kwargs) Union[Tensor, ndarray][source]
Synchronously obtains a
tensorfrom theFeatureStore.- Parameters:
*args – Arguments passed to
TensorAttr.convert_type (bool, optional) – Whether to convert the type of the output tensor to the type of the attribute index. (default:
False)**kwargs – Keyword arguments passed to
TensorAttr.
- Raises:
ValueError – If the input
TensorAttris not fully specified.- Return type:
- multi_get_tensor(attrs: List[TensorAttr], convert_type: bool = False) List[Union[Tensor, ndarray]][source]
Synchronously obtains a list of tensors from the
FeatureStorefor each tensor associated with the attributes inattrs.注意
The default implementation simply iterates over all calls to
get_tensor(). Implementor classes that can provide additional, more performant functionality are recommended to to override this method.- Parameters:
attrs (List[TensorAttr]) – A list of input
TensorAttrobjects that identify the tensors to obtain.convert_type (bool, optional) – Whether to convert the type of the output tensor to the type of the attribute index. (default:
False)
- Raises:
ValueError – If any input
TensorAttris not fully specified.- Return type:
- remove_tensor(*args, **kwargs) bool[source]
Removes a tensor from the
FeatureStore. Returns whether deletion was successful.- Parameters:
*args – Arguments passed to
TensorAttr.**kwargs – Keyword arguments passed to
TensorAttr.
- Raises:
ValueError – If the input
TensorAttris not fully specified.- Return type:
bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。
- update_tensor(tensor: Union[Tensor, ndarray], *args, **kwargs) bool[source]
Updates a
tensorin theFeatureStorewith a new value. Returns whether the update was succesful.注意
实现类可以选择定义更高效的更新方法;默认情况下执行删除和插入操作。
- Parameters:
tensor (torch.Tensor or np.ndarray) – The feature tensor to be updated.
*args – Arguments passed to
TensorAttr.**kwargs – Keyword arguments passed to
TensorAttr.
- Return type:
bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。
- get_tensor_size(*args, **kwargs) Optional[Tuple[int, ...]][source]
Obtains the size of a tensor given its
TensorAttr, orNoneif the tensor does not exist.
- abstract get_all_tensor_attrs() List[TensorAttr][source]
返回所有已注册的张量属性。
- Return type:
- view(*args, **kwargs) AttrView[source]
Returns a view of the
FeatureStoregiven a not yet fully-specifiedTensorAttr.- Return type:
AttrView