Skip to content

Example Trainable Algorithms

Example trainable algorithms to get started with.

New users are recommended to use DenseRadio to ensure that input parameters are compatible. A DenseRadio provides compatible tx and rx methods. When defining transmitters and receivers, ensure the corresponding method is passed.

DenseRadio

Bases: Module

A convenient wrapper for DenseTransmissionAlgorithm and DenseReceptionAlgorithm.

DenseRadio guarantees that the underlying TransmissionAlgorithm and ReceptionAlgorithm are compatible. A DenseRadio provides compatible tx and rx methods. When defining transmitters and receivers, ensure the corresponding method is passed.

Example
>>> radio = DenseRadio(8, 2)
>>> env = NullEnvironment()
>>> env.place({"tx": radio.tx}, {"rx": radio.rx})

__init__(n_input_bits, tx_length_per_bit)

Create a new DenseRadio. See DenseTransmissionAlgorithm.init.

rx(signal)

See DenseReceptionAlgorithm.__call__.

tx(n_timesteps, batch_size=1)

See DenseTransmissionAlgorithm.__call__.

DenseReceptionAlgorithm

Bases: Module

An opinionated ReceptionAlgorithm that uses trainable dense layers.

Do not expect this algorithm to be especially performant. It is an example to help users get started with training receivers using Torchradio.

__call__(signal)

Apply a series of dense layers an input signal.

Parameters:

Name Type Description Default
signal Tensor

A 2D complex valued input tensor.

required

Returns:

Type Description
Reception

A Reception dictionary that records the decoded bits using the key "bits", and the probability of each bit under "bit_probabilities".

__init__(n_bits, window_length)

Create a new DenseReceptionAlgorithm.

Parameters:

Name Type Description Default
n_bits int

An input parameter used to shape the number of parameters in the dense layers. Should be compatible with the n_input_bits specified in DenseTransmissionAlgorithm.

required
window_length int

An input parameter used cutoff unused bits from DenseTransmissionAlgorithm. Usually this is set to n_input_bits * tx_length_per_bit from the instantiation of DenseTransmissionAlgorithm.

required

DenseTransmissionAlgorithm

Bases: Module

An opinionated TransmissionAlgorithm that uses trainable dense layers.

Do not expect this algorithm to be especially performant. It is an example to help users get started with training transmitters using Torchradio.

__call__(n_timesteps, batch_size=1)

Apply a series of dense layers to randomly generated bits.

Parameters:

Name Type Description Default
n_timesteps int

How many timesteps to transmit for.

required
batch_size int

How many transmissions to create in parallel.

1

Returns:

Type Description
Transmission

A Transmission with a complex-valued signal tensor with shape [n_timesteps, batch_size] and a metadata dictionary that records the transmitted bits using the key "bits".

__init__(n_input_bits, tx_length_per_bit)

Create a new DenseTranmissionAlgorithm.

Parameters:

Name Type Description Default
n_input_bits int

An input parameter used to shape the number of parameters in the dense layers.

required
tx_length_per_bit float

An input parameter used to shape the number of parameters in the dense layers.

required