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 tensor to the FeatureStore. 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 TensorAttr is 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 tensor from the FeatureStore.

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 TensorAttr is not fully specified.

Return type:

Union[Tensor, ndarray]

multi_get_tensor(attrs: List[TensorAttr], convert_type: bool = False) List[Union[Tensor, ndarray]][source]

Synchronously obtains a list of tensors from the FeatureStore for each tensor associated with the attributes in attrs.

注意

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 TensorAttr objects 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 TensorAttr is not fully specified.

Return type:

List[Union[Tensor, ndarray]]

remove_tensor(*args, **kwargs) bool[source]

Removes a tensor from the FeatureStore. Returns whether deletion was successful.

Parameters:
Raises:

ValueError – If the input TensorAttr is not fully specified.

Return type:

bool 翻译后的内容: bool 在这个例子中,`bool` 是一个Python函数名称,根据翻译规则1,不需要翻译。因此,翻译后的内容保持不变。

update_tensor(tensor: Union[Tensor, ndarray], *args, **kwargs) bool[source]

Updates a tensor in the FeatureStore with 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, or None if the tensor does not exist.

Return type:

Optional[Tuple[int, ...]]

abstract get_all_tensor_attrs() List[TensorAttr][source]

返回所有已注册的张量属性。

Return type:

List[TensorAttr]

view(*args, **kwargs) AttrView[source]

Returns a view of the FeatureStore given a not yet fully-specified TensorAttr.

Return type:

AttrView