kaira.models.MultipleAccessChannelModel

Inheritance diagram for MultipleAccessChannelModel
- class kaira.models.MultipleAccessChannelModel(encoders: Type[BaseModel] | BaseModel | List[BaseModel] | ModuleList, decoders: Type[BaseModel] | BaseModel | List[BaseModel] | ModuleList, channel: BaseChannel, power_constraint: BaseConstraint, num_devices: int | None = None, *args: Any, **kwargs: Any)[source]
Bases:
BaseModelA model simulating a Multiple Access Channel (MAC).
In a MAC scenario, multiple transmitters (users) send signals simultaneously over a shared channel to a single receiver. The receiver then attempts to decode the messages from all users.
This model supports both shared and separate encoders/decoders based on the provided configuration during initialization. A single decoder instance implies joint decoding.
- encoders
A list of encoder modules. Contains one shared encoder or one encoder per user.
- Type:
nn.ModuleList
- decoders
A list of decoder modules. Contains one shared (joint) decoder or one decoder per user.
- Type:
nn.ModuleList
- channel
The communication channel model.
- Type:
- power_constraint
Power constraint applied to the sum of encoded signals.
- Type:
Methods
Initialize the MultipleAccessChannelModel.
Forward pass through the Multiple Access Channel model.
- __init__(encoders: Type[BaseModel] | BaseModel | List[BaseModel] | ModuleList, decoders: Type[BaseModel] | BaseModel | List[BaseModel] | ModuleList, channel: BaseChannel, power_constraint: BaseConstraint, num_devices: int | None = None, *args: Any, **kwargs: Any)[source]
Initialize the MultipleAccessChannelModel.
- Parameters:
encoders (Union[Type[BaseModel], BaseModel, List[BaseModel], nn.ModuleList]) – Encoder configuration. Can be: - A class (Type[BaseModel]): An instance will be created for each device. - An instance (BaseModel): This instance will be shared across all devices. - A list/ModuleList of instances: One encoder per device. Length must match num_devices.
decoders (Union[Type[BaseModel], BaseModel, List[BaseModel], nn.ModuleList]) – Decoder configuration. Can be: - A class (Type[BaseModel]): A single instance will be created (joint decoder). - An instance (BaseModel): This instance will be used as the single joint decoder. - A list/ModuleList of instances: One decoder per device (separate decoding). Length must match num_devices.
channel (BaseChannel) – The channel model instance.
power_constraint (BaseConstraint) – The power constraint instance.
num_devices (Optional[int]) – The number of users/devices. Required if encoders/decoders are provided as single instances or classes. Inferred if encoders/decoders are lists.
*args – Variable positional arguments passed to the base class and module instantiation.
**kwargs – Variable keyword arguments passed to the base class and module instantiation.
- forward(x: List[Tensor], *args: Any, **kwargs: Any) Tensor[source]
Forward pass through the Multiple Access Channel model.
- Parameters:
x (List[torch.Tensor]) – A list of input tensors, one for each user. Each tensor should have shape (batch_size, message_dim).
*args – Additional positional arguments passed to encoders, channel, and decoder(s).
**kwargs – Additional keyword arguments passed to encoders, channel, and decoder(s).
- Returns:
- The output tensor from the decoder(s).
If joint decoder: (batch_size, decoded_message_dim). If separate decoders: (batch_size, num_users * decoded_message_dim_per_user).
- Return type: