qfnn.qf_fb.c_input module¶
- class qfnn.qf_fb.c_input.ToQuantumData(img_size)¶
Bases:
object
class ToQuantumData is to transform the input image into a unitary matrix to be encoded in quantum unitary matrix.
- class qfnn.qf_fb.c_input.ToQuantumData_Batch¶
Bases:
object
- qfnn.qf_fb.c_input.load_data(interest_num, datapath, isppd, img_size, batch_size, inference_batch_size, is_to_q=True, num_workers=0)¶
Function load_data is to get the DataLoader of MNIST after preprocessing with the interest nums.
- Parameters
interest_num – the specfic label list,such as [3,6]
datapath – the path of MNIST data
isppd – whether the data is loaded from qfMNIST,whch have done preprocessing
img_size – the width /height of input image (width = height)
batch_size – batch size while training
inference_batch_size – batch size while inferencing
is_to_q – whether the output data in loader is to be encoded in quantum unitary matrix
num_workers – for torch.utils.data.DataLoader.
- Returns
a torch.utils.data.DataLoader for training. test_loader: a torch.utils.data.DataLoader for testing.
- Return type
train_loader
- qfnn.qf_fb.c_input.modify_target(target, interest_num)¶
- qfnn.qf_fb.c_input.modify_target_ori(target, interest_num)¶
- qfnn.qf_fb.c_input.select_num(dataset, interest_num)¶
Function select_num is to select the specfic label of a dataset to generate a sub-dataset. :param dataset: a pytorch-datasets :param interest_num: the specfic label list,such as [3,6]
- Returns
a sub-dataset
- Return type
dataset
- qfnn.qf_fb.c_input.to_quantum_matrix(tensor)¶
Function to_quantum_matrix is to transform the input image into a unitary matrix. :param tensor: input image
- Returns
a unitary matrix.
- Return type
output_matrix