Skip to content

Commit

Permalink
Merge pull request #1 from GilesStrong/fixes_and_checks
Browse files Browse the repository at this point in the history
Fixes and checks
  • Loading branch information
GilesStrong authored Jan 28, 2022
2 parents 7343372 + 7a7bf46 commit 1989a58
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 37 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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:
Expand All @@ -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`
Expand Down
5 changes: 3 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
sparse
mistune==0.8.4
2 changes: 1 addition & 1 deletion docs/source/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ muon_regression
===============

.. toctree::
:maxdepth: 1
:maxdepth: 4

muon_regression
3 changes: 1 addition & 2 deletions docs/source/muon_regression.data_proc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions docs/source/muon_regression.experiment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@ Submodules
----------

.. toctree::
:maxdepth: 1


muon_regression.experiment.exp_journal
7 changes: 7 additions & 0 deletions docs/source/muon_regression.fqs.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
muon\_regression.fqs module
===========================

.. automodule:: muon_regression.fqs
:members:
:undoc-members:
:show-inheritance:
6 changes: 1 addition & 5 deletions docs/source/muon_regression.nn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 0 additions & 6 deletions docs/source/muon_regression.plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions docs/source/muon_regression.result_proc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Submodules
----------

.. toctree::
:maxdepth: 1


muon_regression.result_proc.binning
muon_regression.result_proc.correction
10 changes: 8 additions & 2 deletions docs/source/muon_regression.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 8 additions & 6 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
32 changes: 31 additions & 1 deletion muon_regression/nn/conv3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,4 +16,5 @@ sparse==0.11.2
fastcore==1.3.5
lumin==0.8.0
typer==0.3.0
uproot==3.11
uproot==3.11
ipython

0 comments on commit 1989a58

Please sign in to comment.