diff --git a/README.md b/README.md index 416ba83..298b9c7 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,7 @@ # High-Energy Muon Calorimeter Regression Study -Public version of code used in "Calorimetric Measurement of Multi-TeV Muons via Deep Regression" by Jan Kieseler, Giles C. Strong, Filippo Chiandotto, Tommaso Dorigo, & Lukas Layer, (2021), [arXiv:2107.02119 [physics.ins-det]](https://arxiv.org/abs/2107.02119) - -**Warning: This repo is currently being populated with a public version of the research code-base. It is currently incomplete, and has not yet been fully tested. Please check back soon** +Public version of code used in "Calorimetric Measurement of Multi-TeV Muons via Deep Regression" by Jan Kieseler, Giles C. Strong, Filippo Chiandotto, Tommaso Dorigo, & Lukas Layer, [The European Physical Journal C volume 82, Article number: 79 (2022)](https://link.springer.com/article/10.1140%2Fepjc%2Fs10052-022-09993-5) ## Installation @@ -21,7 +19,7 @@ conda env create -f environment.yml This will create a new Conda environment called `muon-regression`, which can be activated using: ``` -conda activate muon-regression +conda activate calo_muon_regression ``` Alternatively: @@ -32,6 +30,8 @@ may be used to install the dependencies. Self-hosted documentation, installation guide, and user guide are available by opening `./docs/build/html/index.html` with a web-browser. +For GPU use (which is highly recommended), please separately install a suitable version of PyTorch based on your drivers. + ## Data Preprocessed datasets are available from https://doi.org/10.5281/zenodo.5163817. The example commands assume the data files are stored in `./data` diff --git a/docs/requirements.txt b/docs/requirements.txt index 1aba778..9121ac4 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,8 +2,9 @@ sphinx==2.2.0 sphinx_rtd_theme sphinx_autodoc_typehints==1.7.0 sphinx_autodoc_annotation==1.0.post1 -lumin==0.7.2 +lumin==0.8.0 typer uproot m2r -sparse \ No newline at end of file +sparse +mistune==0.8.4 diff --git a/docs/source/installation.md b/docs/source/installation.md index 22d48f4..21e6493 100644 --- a/docs/source/installation.md +++ b/docs/source/installation.md @@ -19,7 +19,7 @@ conda env create -f environment.yml This will create a new Conda environment called `muon-regression`, which can be activated using: ``` -conda activate muon-regression +conda activate calo_muon_regression ``` Alternatively: diff --git a/docs/source/modules.rst b/docs/source/modules.rst index 0285759..8ef9154 100644 --- a/docs/source/modules.rst +++ b/docs/source/modules.rst @@ -2,6 +2,6 @@ muon_regression =============== .. toctree:: - :maxdepth: 1 + :maxdepth: 4 muon_regression diff --git a/docs/source/muon_regression.data_proc.rst b/docs/source/muon_regression.data_proc.rst index 72d5eb6..6f1aee3 100644 --- a/docs/source/muon_regression.data_proc.rst +++ b/docs/source/muon_regression.data_proc.rst @@ -10,8 +10,7 @@ Submodules ---------- .. toctree:: - :maxdepth: 1 - + muon_regression.data_proc.data_import muon_regression.data_proc.detector muon_regression.data_proc.pre_proc diff --git a/docs/source/muon_regression.experiment.rst b/docs/source/muon_regression.experiment.rst index 4b252f3..287524d 100644 --- a/docs/source/muon_regression.experiment.rst +++ b/docs/source/muon_regression.experiment.rst @@ -10,6 +10,5 @@ Submodules ---------- .. toctree:: - :maxdepth: 1 - + muon_regression.experiment.exp_journal diff --git a/docs/source/muon_regression.fqs.rst b/docs/source/muon_regression.fqs.rst new file mode 100644 index 0000000..b3165ff --- /dev/null +++ b/docs/source/muon_regression.fqs.rst @@ -0,0 +1,7 @@ +muon\_regression.fqs module +=========================== + +.. automodule:: muon_regression.fqs + :members: + :undoc-members: + :show-inheritance: diff --git a/docs/source/muon_regression.nn.rst b/docs/source/muon_regression.nn.rst index 868df88..0dc7640 100644 --- a/docs/source/muon_regression.nn.rst +++ b/docs/source/muon_regression.nn.rst @@ -10,14 +10,10 @@ Submodules ---------- .. toctree:: - :maxdepth: 1 - + muon_regression.nn.callbacks muon_regression.nn.conv3d - muon_regression.nn.experimental muon_regression.nn.hooks muon_regression.nn.loss muon_regression.nn.metrics muon_regression.nn.models - muon_regression.nn.running_batchnorm - muon_regression.nn.tails diff --git a/docs/source/muon_regression.plotting.rst b/docs/source/muon_regression.plotting.rst index 8b1779d..bb771f8 100644 --- a/docs/source/muon_regression.plotting.rst +++ b/docs/source/muon_regression.plotting.rst @@ -10,13 +10,7 @@ Submodules ---------- .. toctree:: -<<<<<<< Updated upstream - :maxdepth: 4 -======= - :maxdepth: 1 - ->>>>>>> Stashed changes muon_regression.plotting.event_display muon_regression.plotting.fitting muon_regression.plotting.plot_regression diff --git a/docs/source/muon_regression.result_proc.rst b/docs/source/muon_regression.result_proc.rst index b608933..81d0e17 100644 --- a/docs/source/muon_regression.result_proc.rst +++ b/docs/source/muon_regression.result_proc.rst @@ -10,7 +10,6 @@ Submodules ---------- .. toctree:: - :maxdepth: 1 - + muon_regression.result_proc.binning muon_regression.result_proc.correction diff --git a/docs/source/muon_regression.rst b/docs/source/muon_regression.rst index b4d4abc..a3de532 100644 --- a/docs/source/muon_regression.rst +++ b/docs/source/muon_regression.rst @@ -10,10 +10,16 @@ Subpackages ----------- .. toctree:: - :maxdepth: 1 - + muon_regression.data_proc muon_regression.experiment muon_regression.nn muon_regression.plotting muon_regression.result_proc + +Submodules +---------- + +.. toctree:: + + muon_regression.fqs diff --git a/environment.yml b/environment.yml index aee9b70..31a91a4 100644 --- a/environment.yml +++ b/environment.yml @@ -1,19 +1,21 @@ -name: muon-regression +name: calo_muon_regression channels: - conda-forge - defaults dependencies: - - python>=3.6.5 + - python>=3.6.5,<3.8 + - ipython - pip + - pip: + - torch==1.9.0 - seaborn==0.9.0 - matplotlib==3.2.2 - pandas==0.25.0 - - torch==1.9.0 - fastprogress==0.1.21 - - scipy==1.5.4 + - scipy==1.2.0 - numpy==1.21 - - h5py==2.7.1 - - scikit-learn==0.22.0 + - h5py + - scikit-learn==0.22.2 - statsmodels==0.9.0 - sympy==1.1.1 - pdpbox~=0.2.0 diff --git a/muon_regression/nn/conv3d.py b/muon_regression/nn/conv3d.py index 4ad2b4f..843f6f5 100644 --- a/muon_regression/nn/conv3d.py +++ b/muon_regression/nn/conv3d.py @@ -9,12 +9,42 @@ from lumin.nn.models.layers.activations import lookup_act from lumin.nn.models.layers.batchnorms import RunningBatchNorm3d from lumin.utils.misc import to_device, to_tensor -from lumin.nn.models.blocks.conv_blocks import SEBlock3d +from lumin.nn.models.blocks.conv_blocks import SEBlock1d __all__ = ['PreActMuonConv3dBlock'] +class SEBlock3d(SEBlock1d): + r''' + Copyright 2018 onwards Giles Strong + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + Include fix from lumin=0.8.1 + + Squeeze-excitation block [Hu, Shen, Albanie, Sun, & Wu, 2017](https://arxiv.org/abs/1709.01507). + Incoming data is averaged per channel, fed through a single layer of width `n_in//r` and the chose activation, then a second layer of width `n_in` and a sigmoid activation. + Channels in the original data are then multiplied by the learned channe weights. + Arguments: + n_in: number of incoming channels + r: the reduction ratio for the channel compression + act: string representation of argument to pass to lookup_act + lookup_init: function taking choice of activation function, number of inputs, and number of outputs an returning a function to initialise layer weights. + lookup_act: function taking choice of activation function and returning an activation function layer + ''' + + def __init__(self, n_in:int, r:int, act:str='relu', lookup_init:Callable[[str,Optional[int],Optional[int]],Callable[[Tensor],None]]=lookup_normal_init, + lookup_act:Callable[[str],Any]=lookup_act): + super().__init__(n_in=n_in, r=r) + self.n_in,self.r,self.act,self.lookup_init,self.lookup_act = n_in,r,act,lookup_init,lookup_act + self.layers = self._get_layers() + self.sz = [1,1,1] + self.pool = nn.AdaptiveAvgPool3d(self.sz) + + class PreActMuonConv3dBlock(nn.Module): r''' Pre-activation Conv3D block with better placement of BN layers and slightly modified shortcut layers. Energy is expected to be channel 0. diff --git a/requirements.txt b/requirements.txt index d363698..564cdd1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,8 +5,8 @@ torch==1.9.0 fastprogress==0.1.21 scipy==1.5.4 numpy==1.21 -h5py==2.7.1 -scikit-learn==0.22.0 +h5py +scikit-learn==0.22.2 statsmodels==0.9.0 sympy==1.1.1 pdpbox~=0.2.0 @@ -16,4 +16,5 @@ sparse==0.11.2 fastcore==1.3.5 lumin==0.8.0 typer==0.3.0 -uproot==3.11 \ No newline at end of file +uproot==3.11 +ipython \ No newline at end of file