CRISP Module¶
This module provides an interface in Python to perform polar encoding, and decoding using Successive cancellation, as well as the CRISP-CNN and CRISP-RNN decoders.
Functions¶
- class deepcommpy.crisp.PolarCode(N, K, F=None, rs=None, infty=1000.0)¶
- __init__(N, K, F=None, rs=None, infty=1000.0)¶
Turbo Code object. Includes encoding and decoding functions.
Parameters¶
- Nint
Block length.
- Kint
Message length.
- Flist of ints (optional)
List of frozen bit positions.
- rslist of ints (optional)
Reliability sequence.
- inftyfloat (optional)
Large number to use for infinity.
- crisp_cnn_decode(y, net=None)¶
Decode Polar codes using CRISP CNN.
Parameters¶
- ytorch.Tensor
Received signal. Shape: (batch_size, N)
- nettorch.nn.Module, optional
CRISP CNN net. If None, default net is used. Default: None Default net is available for Polar(64, 22). Default nets should be stored in deepcommpy.crisp.models.cnn_n{N}_k{K}.pt. The checkpoint should have keys ‘model_state_dict’ and ‘config’.
- crisp_rnn_decode(y, net=None)¶
Decode Polar codes using CRISP GRU.
Parameters¶
- ytorch.Tensor
Received signal. Shape: (batch_size, N)
- nettorch.nn.Module, optional
CRISP GRU net. If None, default net is used. Default: None Default net is available for Polar(64, 22). Default nets should be stored in deepcommpy.crisp.models.rnn_n{N}_k{K}.pt. The checkpoint should have keys ‘model_state_dict’ and ‘config’.
- encode(message, custom_info_positions=None)¶
Encode a message using the polar code using the Plotkin method.
Parameters¶
- messagetorch.Tensor
The message to encode, shape (batch, k)
- custom_info_positionstorch.Tensor (optional)
The positions of the information bits, shape (k). If None, the default info positions are used.
- class deepcommpy.crisp.RNN_Model(config)¶
CRISP-GRU model class.
Parameters¶
- configdict
Dictionary containing the model configuration. Sample config provided in the provided sample models.
- __init__(config)¶
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- forward(input, hidden, Fy=None)¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class deepcommpy.crisp.convNet(config)¶
CRISP-CNN model class.
Parameters¶
- configdict
Dictionary containing the model configuration. Sample config provided in the provided sample models.
- __init__(config)¶
Initializes internal Module state, shared by both nn.Module and ScriptModule.
- forward(noisy_enc)¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- deepcommpy.crisp.crisp_rnn_test(polar, device, net=None, config=None)¶
Test example for CRISP-RNN.
Parameters¶
- polarPolarCode
Polar code object.
- devicetorch.device
Device to use for computations. Eg: torch.device(‘cuda:0’) or torch.device(‘cpu’)
- netCRISP_RNN, optional
CRISP-RNN model object. If None, then default model is used.
- configdict, optional
Configuration dictionary. Example config provided as deepcommpy/crisp/test_config.json.
- deepcommpy.crisp.crisp_cnn_test(polar, device, net=None, config=None)¶
Test example for CRISP-CNN.
Parameters¶
- polarPolarCode
Polar code object.
- devicetorch.device
Device to use for computations. Eg: torch.device(‘cuda:0’) or torch.device(‘cpu’)
- netCRISP_CNN, optional
CRISP-CNN model object. If None, default model is used.
- configdict, optional
Configuration dictionary. Example config provided as deepcommpy/crisp/test_config.json.