Download experiments/flowmo/src/train.py from cccat6/FlowMo-WM: direct link, hf CLI and curl.
- Browser
- Download file 476 Bytes
-
https://huggingface.co/cccat6/FlowMo-WM/resolve/dd3258b67d055ee2ef6d024c562dab46d4d25f1a/experiments/flowmo/src/train.py
- Command line
-
hf download hf://cccat6/FlowMo-WM@dd3258b67d055ee2ef6d024c562dab46d4d25f1a/experiments/flowmo/src/train.py
-
curl -L -o train.py https://huggingface.co/cccat6/FlowMo-WM/resolve/dd3258b67d055ee2ef6d024c562dab46d4d25f1a/experiments/flowmo/src/train.py
476 Bytes
| """FlowMo training entry point.""" | |
| import torch.nn.functional as F | |
| def train(config): | |
| """Train FlowMo on the configured dataset.""" | |
| model = config["model"] | |
| optimizer = config["optimizer"] | |
| images, actions, future_actions, targets = config["batch"] | |
| pred = model.rollout(images, actions, future_actions) | |
| loss = F.mse_loss(pred, targets) | |
| optimizer.zero_grad(set_to_none=True) | |
| loss.backward() | |
| optimizer.step() | |
| return float(loss.detach()) | |