Skip to content

Commit

Permalink
add option for unique sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
rakow committed Sep 10, 2024
1 parent 1aa0acc commit 014739e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion matsim/scenariogen/network/run_opt_freespeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def setup(parser: argparse.ArgumentParser):
parser.add_argument("--ref-size", type=int, help="Number of links (needed for individual model)", default=0)
parser.add_argument("--learning-rate", type=float, help="Start learning rate", default=1e-4)
parser.add_argument("--batch-size", type=int, help="Batch size", default=128)
parse.add_argument("--sample-unique", help="Every batch element is a different element", action="store_true", default=False)
parser.add_argument("--output", help="Output folder for params", default="output-params")


Expand Down Expand Up @@ -156,7 +157,7 @@ def main(args):
for j in range(batches):
key = random.PRNGKey(r.getrandbits(31))

idx = random.choice(key, jnp.arange(0, xs.shape[0]), replace=False, shape=(batch_size,))
idx = random.choice(key, jnp.arange(0, xs.shape[0]), replace=not args.sample_unique, shape=(batch_size,))

grads = m.loss(m.params, xs[idx], ys[idx])

Expand Down

0 comments on commit 014739e

Please sign in to comment.