paddlespeech.t2s.training.updater module

class paddlespeech.t2s.training.updater.UpdaterBase(init_state=None)[source]

Bases: object

An updater is the abstraction of how a model is trained given the dataloader and the optimizer.

The update_core method is a step in the training loop with only necessary operations (get a batch, forward and backward, update the parameters).

Other stuffs are made extensions. Visualization, saving, loading and periodical validation and evaluation are not considered here.

But even in such simplist case, things are not that simple. There is an attempt to standardize this process and requires only the model and dataset and do all the stuffs automatically. But this may hurt flexibility.

If we assume a batch yield from the dataloader is just the input to the model, we will find that some model requires more arguments, or just some keyword arguments. But this prevents us from over-simplifying it.

From another perspective, the batch may includes not just the input, but also the target. But the model's forward method may just need the input. We can pass a dict or a super-long tuple to the model and let it pick what it really needs. But this is an abuse of lazy interface.

After all, we care about how a model is trained. But just how the model is used for inference. We want to control how a model is trained. We just don't want to be messed up with other auxiliary code.

So the best practice is to define a model and define a updater for it.

Methods

load

save

set_state_dict

state_dict

update

load(path)[source]
save(path)[source]
set_state_dict(state_dict)[source]
state_dict()[source]
update(batch)[source]
class paddlespeech.t2s.training.updater.UpdaterState(iteration: int = 0, epoch: int = 0)[source]

Bases: object

epoch: int = 0
iteration: int = 0