"torchvision/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "f0a13fdcc00a1f76745d019b37346ecea375f500"
Unverified Commit 964fd020 authored by LastWhisper's avatar LastWhisper Committed by GitHub
Browse files

[Example] Add early stop option for better regression test. (#6545)

parent d79701db
...@@ -370,6 +370,8 @@ def train(args, device, g, reverse_eids, seed_edges, model, use_uva): ...@@ -370,6 +370,8 @@ def train(args, device, g, reverse_eids, seed_edges, model, use_uva):
loss.backward() loss.backward()
opt.step() opt.step()
total_loss += loss.item() total_loss += loss.item()
if (it + 1) == args.early_stop:
break
print(f"Epoch {epoch:05d} | Loss {total_loss / (it + 1):.4f}") print(f"Epoch {epoch:05d} | Loss {total_loss / (it + 1):.4f}")
...@@ -387,6 +389,12 @@ def parse_args(): ...@@ -387,6 +389,12 @@ def parse_args():
default=512, default=512,
help="Batch size. Default: 512", help="Batch size. Default: 512",
) )
parser.add_argument(
"--early-stop",
type=int,
default=0,
help="0 means no early stop, otherwise stop at the input-th step",
)
parser.add_argument( parser.add_argument(
"--mode", "--mode",
default="mixed", default="mixed",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment