MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / forward_step

Function forward_step

SwissArmyTransformer/examples/t5/finetune_t5.py:46–64  ·  view source on GitHub ↗

Forward step.

(data_iterator, model, args, timers)

Source from the content-addressed store, hash-verified

44
45
46def forward_step(data_iterator, model, args, timers):
47 """Forward step."""
48
49 # Get the batch.
50 timers('batch generator').start()
51 input_ids, position_ids, mask = get_batch(
52 data_iterator, args, timers)
53 timers('batch generator').stop()
54 # Forward model.
55
56 enc, logits, *mems = model(
57 enc_input_ids=input_ids,
58 dec_input_ids=input_ids,
59 enc_position_ids=position_ids,
60 dec_position_ids=position_ids,
61 dec_attention_mask=mask)
62 # logits, *mems = model(tokens, position_ids, attention_mask)
63 loss = logits.mean()
64 return loss, {}
65
66def create_dataset_function(path, args):
67

Callers

nothing calls this directly

Calls 3

startMethod · 0.80
stopMethod · 0.80
get_batchFunction · 0.70

Tested by

no test coverage detected