pesedoA = 57
numCRC = 24
crcPoly = [24, 23, 21, 20, 17, 15, 13, 12, 8, 4, 2, 1, 0]
K = A + numCRC
PesodoK = pesedoA + numCRC
SNRdB = 0
SNR = 10**(SNRdB / 10)
sigma = np.sqrt(1 / SNR)

experiment_name = "CDF-N={:d}-K=[{:d}, {:d}]-SNR={:.1f} dB".format(
    N, A, pesedoA, SNRdB)
if os.path.isdir(
        os.path.join(os.path.pardir, "BD_DMetric_EPFL", experiment_name)):
    shutil.rmtree(
        os.path.join(os.path.pardir, "BD_DMetric_EPFL", experiment_name))
tracer = Tracer('../BD_DMetric_EPFL').attach(experiment_name)

codeConstructor = PolarCodeConstructor(N,
                                       K,
                                       QPath=os.path.join(
                                           os.getcwd(),
                                           "../reliable_sequence.txt"))
frozenbits, messagebits, frozenbits_indicator, messagebits_indicator = codeConstructor.PW(
    N, K)
polarEncoder = PolarEnc(N, K, frozenbits, messagebits)
nodeIdentifier = NodeIdentifier(N, K, frozenbits, messagebits)
nodeType = nodeIdentifier.run()
DMetricCalculator = EPFLDMetricCalculator(N, K, nodeType, frozenbits,
                                          messagebits)

frozenbitsPesedo, messagebitsPesedo, _, _ = codeConstructor.PW(N, PesodoK)
예제 #2
0
# Simulation Parameters
L = args.L
RUN_FAR = args.RUN_FAR
RUN_MDR = 1 - RUN_FAR

# simulation parameter configuration
SNRdBTest = [0, 1, 2, 3, 4]

# initialize Trace instance to maintain simulation hyper-parameters and results and images
if RUN_MDR == True:
    experiment_name = "MDR-L = {:d}".format(L)
else:
    experiment_name = "FAR-L = {:d}".format(L)
if os.path.isdir(os.path.join(os.getcwd(), "BD_Benchmark", experiment_name)):
    shutil.rmtree(os.path.join(os.getcwd(), "BD_Benchmark", experiment_name))
tracer = Tracer('BD_Benchmark').attach(experiment_name)
configure = {"L": L,
             "SNRdBTest":SNRdBTest}
tracer.store(Config(configure))

# Initialize PDCCH candidate generator and corresponding decoders
PDCCHGenerator = CandidateGenerator()
CRCEncoder = CRCEnc(PDCCHGenerator.numCRCBits, PDCCHGenerator.crcPoly)
CASCLDecoders = []
for i in range(PDCCHGenerator.numAggregationLevel):
    N = PDCCHGenerator.codewordLengthPerAggregationLevel[i]
    for m in range(2):
        A = PDCCHGenerator.numInformationBits[m]
        K = A +  PDCCHGenerator.numCRCBits
        frozenbits_indicator = PDCCHGenerator.frozenbits_indicator_set[i][m]
        messagebits_indicator = PDCCHGenerator.messagebits_indicator_set[i][m]
예제 #3
0
import shutil

N = 512
A = 57
numCRC = 16
K = A + numCRC
PesodoK = 32 + numCRC
rate = A/N
SNRdB = 3
SNR = 10**(SNRdB/10)
sigma = np.sqrt(1/SNR)

experiment_name = "CDF-N={:d}-K={:d}-SNR={:.1f}".format(N, K, SNR)
if os.path.isdir(os.path.join(os.getcwd(), "BD_DMetric_EPFL", experiment_name)):
    shutil.rmtree(os.path.join(os.getcwd(), "BD_DMetric_EPFL", experiment_name))
tracer = Tracer('BD_DMetric_EPFL').attach(experiment_name)

codeConstructor = PolarCodeConstructor(N, K, QPath=os.path.join(os.getcwd(), "reliable_sequence.txt"))
frozenbits, messagebits, frozenbits_indicator, messagebits_indicator = codeConstructor.PW(N, K)
polarEncoder = PolarEnc(N, K, frozenbits, messagebits)
nodeIdentifier = NodeIdentifier(N, K, frozenbits, messagebits)
nodeType = nodeIdentifier.run()
DMetricCalculator = EPFLDMetricCalculator(N, K, nodeType, frozenbits, messagebits)

frozenbitsPesedo, messagebitsPesedo, _, _ = codeConstructor.PW(N, PesodoK)
polarPesedoEncoder = PolarEnc(N, PesodoK, frozenbitsPesedo, messagebitsPesedo)

crcEnc = CRCEnc(crc_n=numCRC, crc_polynominal=[16, 15, 2, 0])


# Try Complete Noise / Random Codewords / Regular Polar Codes
예제 #4
0
        messagebits_indicator = PDCCHGenerator.messagebits_indicator_set[i][m]
        SCLOneDec = CASCLDecoder(N=N, K=K, A=A, L=L1, frozen_bits=frozenbits_indicator, message_bits=messagebits_indicator,
                                crc_n=PDCCHGenerator.numCRCBits, crc_p=PDCCHGenerator.crcPoly)
        CASCLDec = CASCLDecoder(N=N, K=K, A=A, L=L2, frozen_bits=frozenbits_indicator, message_bits=messagebits_indicator,
                                crc_n=PDCCHGenerator.numCRCBits, crc_p=PDCCHGenerator.crcPoly)
        SCLOneDecoders.append(SCLOneDec)
        CASCLDecoders.append(CASCLDec)

# Initialize Tracer instance to maintain simulation hyper-parameters, results and images
if RUN_MDR == True:
    experiment_name = "MDR-L1={:d}-L2={:d}-Omega={:d}".format(L1, L2, Omega)
else:
    experiment_name = "FAR-L1={:d}-L2={:d}-Omega={:d}".format(L1, L2, Omega)
if os.path.isdir(os.path.join(os.getcwd(), "BD_Kuangda", experiment_name)):
    shutil.rmtree(os.path.join(os.getcwd(), "BD_Kuangda", experiment_name))
tracer = Tracer('BD_Kuangda').attach(experiment_name)
configure = {"L1": L1,
             "L2": L2,
             "DCI Lengths": PDCCHGenerator.numInformationBits,
             "Omega": Omega,
             }
tracer.store(Config(configure))

if RUN_MDR == True:
    # Start Simulation FAR
    print("Simulation for MDR")
    # simulation parameter configuration
    numSimulation = 10**4
    SNRdBTest = [0, 1, 2, 3, 4, 5]
    MDR_SNR = []
    FER_SNR = []
예제 #5
0
파일: demo.py 프로젝트: xwjBupt/torchtracer
            'Epoch #{:03d}\ttrain_loss: {:.4f}\tvalid_loss: {:.4f}'.format(
                epoch, train_loss, valid_loss))

        train_losses.append(train_loss)
        valid_losses.append(valid_loss)
    tracer.epoch_bar.close()
    tracer.store(Model(model))

    plt.plot(train_losses, label='train loss', c='b')
    plt.plot(valid_losses, label='valid loss', c='r')
    plt.title('Demo Learning on SQRT')
    plt.legend()
    tracer.store(plt.gcf(), 'losses.png')


if __name__ == '__main__':
    net = nn.Sequential(nn.Linear(1, 6, True), nn.ReLU(),
                        nn.Linear(6, 12, True), nn.ReLU(),
                        nn.Linear(12, 12, True), nn.ReLU(),
                        nn.Linear(12, 1, True))
    args = {
        'epoch_n': 120,
        'batch_size': 50,
        'criterion': nn.MSELoss(),
        'optimizer': torch.optim.RMSprop(net.parameters(), lr=1e-3),
        'dataloader': DataLoader(dataset=torchvision.datasets.fakedata)
    }
    tracer = Tracer('checkpoints').attach('rabbit')
    train(net, tracer, **args)
    tracer.detach()