Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions doc/sphinx/source/n3fit/runcard_detailed.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ The fraction of events that are considered for the training and validation sets

It is possible to run a fit with no validation set by setting the fraction to ``1.0``, in this case the training set will be used as validation set.

The random seed for the training/validation split is defined by the variable ``trvlseed``.
By default the seed is further modified by the replica index, but it is possible
to fix it such that it is the same for all replicas with ``same_trvl_per_replica``
(``false`` by default).

.. code-block:: yaml

trvlseed: 7
same_trvl_per_replica: true


.. _networkarch-label:

Expand Down
4 changes: 3 additions & 1 deletion validphys2/src/validphys/n3fit_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@

log = logging.getLogger(__name__)

def replica_trvlseed(replica, trvlseed):
def replica_trvlseed(replica, trvlseed, same_trvl_per_replica=False):
"""Generates the ``trvlseed`` for a ``replica``."""
# TODO: move to the new infrastructure
# https://numpy.org/doc/stable/reference/random/index.html#introduction
np.random.seed(seed=trvlseed)
if same_trvl_per_replica:
return np.random.randint(0, pow(2, 31))
for _ in range(replica):
res = np.random.randint(0, pow(2, 31))
return res
Expand Down