Skip to main content

shim

Pytorch implementation of the tensor shim.

Classes

PyTorchBackendTensorShim

class PyTorchBackendTensorShim():

PyTorch backend shim/bridge for converting from/to PyTorch tensors.

Ancestors

Static methods


def clamp_params(    p: _TensorLike, prime_q: int, precision: int, num_workers: int,)> bitfount.types._TensorLike:

Method for clipping params for secure sharing.

Constrains the parameters for secure sharing to be within the required range for secure sharing. Used only when steps_between_parameter_updates is 1.

Arguments

  • p: The tensor to be constrained.
  • prime_q: The prime use for secret aggregation.
  • precision: The precision used for secret aggregation.
  • num_workers: The number of workers taking part in the secure aggregation.

Returns The clamped parameters.

def is_tensor(p: Any)> bool:

See base class.

def to_list(p: Union[np.ndarray, _TensorLike])> List[float]:

See base class.

def to_numpy(t: Union[_TensorLike, List[float]])> numpy.ndarray:

See base class.

def to_tensor(p: Sequence, **kwargs: Any)> bitfount.types._TensorLike:

See base class.

Variables

  • static nested_fields : ClassVar[Dict[str, Mapping[str, Any]]]