Just a quick question:
whenever the learner.show_results()
opens a new random image from the validation
dataset, how does it know to reach out only to the list files of validation? Is it stored at dsets.train[1]
or somewhere else?
The learner contains a reference to the Dataloaders in dls
. dls.valid
contains the validation Dataloaders, which has an items
attr with the list of file name.
Hey I’d like to ask for some guidance:
I’m trying to pack my set of functions/classes into a package. Some of them use TensorBase
, but after distributing and installing, it says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\pycharm\a\src\newpackage.py", line 75, in <module>
class NewKindTensor(TensorBase):
NameError: name 'TensorBase' is not defined
Shall I literally import it from wherever it is by using from pytorch import TensorBase
? Can’t this be defined when I import fastai anyway?
Thanks
To anyone it may help. I solved this by using:
from fastai.vision.all import *
from fastai.vision.data import *
Another question. I’m trying to use ShowGraphCallback
but make it not only display, but also save it finally as a GIF file. I tried to search for some pre-implementations but didn’t find any. What shall I take into consideration when diving into the deep back-stage code and change there?
# Cell
class ShowGraphCallback(Callback):
"Update a graph of training and validation loss"
run_after,run_valid=ProgressCallback,False
def before_fit(self):
self.run = not hasattr(self.learn, 'lr_finder') and not hasattr(self, "gather_preds")
self.nb_batches = []
assert hasattr(self.learn, 'progress')
def after_train(self): self.nb_batches.append(self.train_iter)
def after_epoch(self):
"Plot validation loss in the pbar graph"
rec = self.learn.recorder
iters = range_of(rec.losses)
val_losses = [v[1] for v in rec.values]
x_bounds = (0, (self.n_epoch - len(self.nb_batches)) * self.nb_batches[0] + len(rec.losses))
y_bounds = (0, max((max(Tensor(rec.losses)), max(Tensor(val_losses)))))
self.progress.mbar.update_graph([(iters, rec.losses), (self.nb_batches, val_losses)], x_bounds, y_bounds)
Only now saw your post… Let me know if you need any help with SeeMe.ai or general deployment…