federated/utils/compression_utils.py
def build_encoded_broadcast_fn(weights: tf.Tensor) -> te.core.Encoder:
    """Function for encoding weights with uniform quantization.

    Args:
        weights (tf.Tensor): Weights of the model.

    Returns:
        te.core.Encoder: Encoder.
    """
    if weights.shape.num_elements() > 0:
        return te.encoders.as_simple_encoder(
            te.encoders.uniform_quantization(bits=4),
            tf.TensorSpec(weights.shape, weights.dtype),
        )

    else:
        return te.encoders.as_simple_encoder(
            te.encoders.identity(), tf.TensorSpec(weights.shape, weights.dtype)
        )
Function for encoding weights with uniform quantization.

    Args:
        weights (tf.Tensor): Weights of the model.

    Returns:
        te.core.Encoder: Encoder.
    
Function for encoding weights with uniform quantization.
Function for encoding weights with uniform quantization .
def build_encoded_broadcast_fn(weights: tf.Tensor) -> te.core.Encoder:
    if weights.shape.num_elements() > 0:
        return te.encoders.as_simple_encoder(
            te.encoders.uniform_quantization(bits=4),
            tf.TensorSpec(weights.shape, weights.dtype),
        )
    else:
        return te.encoders.as_simple_encoder(
            te.encoders.identity(), tf.TensorSpec(weights.shape, weights.dtype)
        )
def build_encoded_broadcast_fn ( weights : tf . Tensor ) -> te . core . Encoder : if weights . shape . num_elements ( ) > 0 : return te . encoders . as_simple_encoder ( te . encoders . uniform_quantization ( bits = 4 ) , tf . TensorSpec ( weights . shape , weights . dtype ) , ) else : return te . encoders . as_simple_encoder ( te . encoders . identity ( ) , tf . TensorSpec ( weights . shape , weights . dtype ) )
Function for encoding weights with uniform quantization.
Function for encoding weights with uniform quantization .
"""Function for encoding weights with uniform quantization.

    Args:
        weights (tf.Tensor): Weights of the model.

    Returns:
        te.core.Encoder: Encoder.
    """
None
te.core.Encoder
weights
tf.Tensor
Weights of the model.
Weights of the model .