Custom prediction problem

Hi, I create the learner by the pytorch model and data. How should I achieve the prediction by the learner?
data = Dataset(TRN)
trn, val = train_test_split(data, test_size=0.2)
trn = DataLoader(trn, batch_size=4, shuffle=True)
val = DataLoader(val, batch_size=4, shuffle=False)
data = DataBunch(trn, val)

learn = Learner(data, U_Net(), opt_func=torch.optim.Adam, metrics=[jaccard_dis, jaccard_coef_int])
learn.loss_func = nn.BCELoss()

The trn and val both are pytorch dataloader. When I try to run learn.predict, the error is as follows:
AttributeError: 'list' object has no attribute 'set_item'

As far as I know, learn.predict requires the DataBunch to be created with the data_block api. In addition, the argument you pass to it must inherit from ItemBase, such as the Image class. Just to be clear, are you trying to get a single prediction or all train/validation set predictions? If it is the latter, you want to use learn.get_preds.

I’d recommend loading your data with the data_block api, so that you can use the full array of learner functions that depend on it. However, if you just want to get a single prediction with your current setup you can just grab the input tensor and directly pass it to learn.model.

Thanks for your reply. It is difficult to create the DataBunch in my datasets. I will try the method you recommended.