[][src]Struct xaynet::mask::Aggregation

pub struct Aggregation { /* fields omitted */ }

An aggregator for masks and masked models.

Implementations

impl Aggregation[src]

pub fn new(config: MaskConfig, object_size: usize) -> Self[src]

Creates a new, empty aggregator for masks or masked models.

pub fn len(&self) -> usize[src]

Gets the length of the aggregated mask object.

pub fn config(&self) -> MaskConfig[src]

Gets the masking configuration of the aggregator.

pub fn validate_unmasking(
    &self,
    mask: &MaskObject
) -> Result<(), UnmaskingError>
[src]

Validates if unmasking of the aggregated masked model with the given mask may be safely performed.

This should be checked before calling unmask(), since unmasking may return garbage values otherwise.

Errors

Fails in one of the following cases:

  • The aggregator has not yet aggregated any models.
  • The number of aggregated masked models is larger than the chosen masking configuration allows.
  • The masking configuration of the aggregator and of the mask don't coincide.
  • The length of the aggregated masked model and the mask don't coincide.
  • The mask itself is invalid.

Even though it does not produce any meaningful values, it is safe and technically possible due to the MaskObject type to validate, that:

  • a mask may unmask another mask
  • a masked model may unmask a mask
  • a masked model may unmask another masked model

pub fn unmask(self, mask: MaskObject) -> Model[src]

Unmasks the aggregated masked model with the given mask.

It should be checked that validate_unmasking() succeeds before calling this, since unmasking may return garbage values otherwise. The unmasking is performed in opposite order as described for mask().

Panics

This may only panic if validate_unmasking() fails.

Even though it does not produce any meaningful values, it is safe and technically possible due to the MaskObject type to unmask:

  • a mask with another mask
  • a mask with a masked model
  • a masked model with another masked model

if validate_unmasking() returns true.

pub fn validate_aggregation(
    &self,
    object: &MaskObject
) -> Result<(), AggregationError>
[src]

Validates if aggregation of the aggregated mask object with the given object may be safely performed.

This should be checked before calling aggregate(), since aggregation may return garbage values otherwise.

Errors

Fails in one of the following cases:

  • The masking configuration of the aggregator and of the object don't coincide.
  • The length of the aggregated masks or masked model and the object don't coincide. If the aggregator is empty, then an object of any length may be aggregated.
  • The new number of aggregated masks or masked models would exceed the number that the chosen masking configuration allows.
  • The object itself is invalid.

Even though it does not produce any meaningful values, it is safe and technically possible due to the MaskObject type to validate, that a mask may be aggregated with a masked model.

pub fn aggregate(&mut self, object: MaskObject)[src]

Aggregates the aggregated mask object with the given object.

It should be checked that validate_aggregation() succeeds before calling this, since aggregation may return garbage values otherwise.

Errors

Even though it does not produce any meaningful values, it is safe and technically possible due to the MaskObject type to aggregate a mask with a masked model if validate_aggregation() returns true.

Trait Implementations

impl Debug for Aggregation[src]

impl From<MaskObject> for Aggregation[src]

impl Into<MaskObject> for Aggregation[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]