Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DL4Jets changes #5

Open
wants to merge 489 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
489 commits
Select commit Hold shift + click to select a range
19859d7
changed order
jkiesele Feb 21, 2020
ab8a662
changes in base, move to TF2
jkiesele Feb 21, 2020
a54e660
tiny change
jkiesele Feb 23, 2020
3789a67
TF2.1 and some bells and whistles on DataCollection and roc curve
jkiesele Feb 26, 2020
683b7c7
cuda 10.1
jkiesele Feb 26, 2020
7dca38f
skim bugfix
jkiesele Feb 27, 2020
f9362b6
snapsho
jkiesele Feb 28, 2020
61b5156
to auto builds
jkiesele Feb 28, 2020
bea7dc5
label update
jkiesele Feb 28, 2020
6d221fc
tag snapsho
jkiesele Feb 28, 2020
b62732b
done tagging
jkiesele Feb 28, 2020
a90cf46
2.2.+2.1 commit
jkiesele Feb 28, 2020
d57e28f
2.2 tf1.15
jkiesele Feb 28, 2020
68eebee
update
jkiesele Feb 28, 2020
0b58866
split bc of auto builds
jkiesele Feb 28, 2020
f76393a
2.2 tf2.1
jkiesele Feb 28, 2020
02b2951
TF1.15 tag
jkiesele Feb 28, 2020
b3030de
latest tag master
jkiesele Feb 28, 2020
08a1674
readme
jkiesele Mar 9, 2020
f957fb1
splitting and test
jkiesele Mar 9, 2020
9346b9e
removing debug output
jkiesele Mar 10, 2020
e68a9a3
fixes for generator in case the data runs out
jkiesele Mar 10, 2020
4e3b4e0
compressed docker file
jkiesele Mar 10, 2020
406e070
incorporating options for eager training
jkiesele Mar 13, 2020
51706e5
some new debug outputs and testing scripts
jkiesele Mar 13, 2020
a12114f
cleanup and finally fixed predetermined batch size problem with ragge…
jkiesele Mar 13, 2020
4d10c0e
removed stray debug message
jkiesele Mar 13, 2020
4c23c6d
small performance improvement
jkiesele Mar 13, 2020
caec2db
added versioning and some viewer tools
jkiesele Mar 17, 2020
34c4050
CUDA 10.1 as default in base
jkiesele Mar 17, 2020
3bb3eb5
cuda 10.1
jkiesele Mar 18, 2020
f357c28
more debug functions for generator
jkiesele Mar 24, 2020
93c6e60
moving to python3 step 1. testEnvironment works
jkiesele Mar 26, 2020
e2994da
first auto container attempt
jkiesele Mar 26, 2020
0beb2d4
snapshot of py3 dev
jkiesele Mar 27, 2020
eb1438f
some updates
jkiesele Mar 27, 2020
1e60b43
experimental docker file
jkiesele Mar 27, 2020
21daf26
python3 migration, will tag as 3.0
jkiesele Mar 28, 2020
f080210
readme
jkiesele Mar 28, 2020
da06ea1
backups after n batches
jkiesele Mar 28, 2020
d86939d
tf2.2rc2 in exp
jkiesele Mar 28, 2020
325c6c1
torch geometric in base and fix for gpu selection in training base
jkiesele Apr 3, 2020
e0d8c0d
readme for non keras training
jkiesele Apr 14, 2020
429feb9
more py3 adjustments
jkiesele Apr 15, 2020
545ae25
another py3 fix
jkiesele Apr 15, 2020
2073963
some features for ROCs, python3 fix in preprocessing, valdata can be …
jkiesele Apr 20, 2020
3c9200a
some more predict options and - more importantly - bugfix for trainda…
jkiesele Apr 21, 2020
c55fff3
slicing for simpleArrays and massively improved data pipeline, less c…
jkiesele Apr 21, 2020
187f0e2
also made >8GB safe for split function
jkiesele Apr 21, 2020
2c7c7b4
bugfix in generator if used for more than one call in buffer mode
jkiesele Apr 30, 2020
62c092f
fixes
jkiesele May 1, 2020
b57cb68
some improvements
jkiesele May 11, 2020
649cde3
some fixes and more sanity checks in the data pipeline
jkiesele May 19, 2020
51b87ee
fixed problem with 1 element row splits
jkiesele May 19, 2020
b877995
batch plotting
jkiesele May 20, 2020
5aee46f
fixed possible bug - thanks Max
jkiesele May 22, 2020
43a821e
do not reset weighterobjects
emilbols May 22, 2020
9a3126c
Merge pull request #43 from emilbols/WeighterObjects
jkiesele May 22, 2020
4aac67f
Fix layer freeze
emilbols May 22, 2020
fb438a5
Merge pull request #44 from emilbols/WeighterObjects
jkiesele May 22, 2020
a218a43
some better help
jkiesele May 25, 2020
22fe972
Merge branch 'master' of https://github.com/DL4Jets/DeepJetCore
jkiesele May 25, 2020
bf109d8
better help
jkiesele May 25, 2020
9e21160
small bugfix
jkiesele May 27, 2020
0469541
Make convertDCtoNP usuable, adding a argument to do it on a subset of…
emilbols May 29, 2020
f48c464
added the load_in_mem method
emilbols May 29, 2020
972c73f
Merge pull request #45 from emilbols/ConvertToNumpy
jkiesele May 29, 2020
9690c68
fix wrong variable name
emilbols Jun 2, 2020
0326c8e
Merge pull request #46 from emilbols/ConvertToNumpy
jkiesele Jun 2, 2020
d08d885
small fixes and safety measures
jkiesele Jun 7, 2020
3d7a58d
small fix for recover
jkiesele Jun 11, 2020
b20cdcb
fixes
jkiesele Jun 12, 2020
e618fa6
better modularisation of data generator and data collection. notice r…
jkiesele Jun 12, 2020
0980b44
and add the forgotten file
jkiesele Jun 12, 2020
9385aff
some more helpful text
jkiesele Jun 12, 2020
ccb1fa4
fixed readme
jkiesele Jun 12, 2020
e9e8df3
small fix
jkiesele Jun 17, 2020
75f24a1
fix
jkiesele Jun 17, 2020
4ced8b6
no hooks
jkiesele Jun 19, 2020
fd96e0e
zenodo citation
jkiesele Jun 23, 2020
6fa29b3
just the link is enough
jkiesele Jun 23, 2020
e48d14f
more versatile inputs to predict.py , more robust file reading handli…
jkiesele Jul 7, 2020
3abb832
better documentation and reaidng initial model weights easily
jkiesele Jul 15, 2020
7a2ed6c
more bells and whistles on predict
jkiesele Jul 15, 2020
26aa4e3
easy recover training
jkiesele Jul 16, 2020
8953dda
added stop gradient layer
jkiesele Aug 3, 2020
7ef694c
fix lxplus
emilbols Aug 5, 2020
b0000bc
Merge pull request #49 from emilbols/FixLxplus
jkiesele Aug 5, 2020
f806409
script to validate input files
jkiesele Aug 14, 2020
61f9ed4
some fixes
jkiesele Aug 14, 2020
33f13e5
rebuild model when taking weights
jkiesele Aug 18, 2020
0535c35
more printout for model tools
jkiesele Aug 19, 2020
6f6f19c
more testing, small fix
jkiesele Sep 7, 2020
5f10559
mostly new containers
jkiesele Sep 8, 2020
b8347d8
switch to TF2.3
jkiesele Sep 20, 2020
2b0f80d
better handling of inpurs of other types
jkiesele Sep 23, 2020
726516e
small fixes
jkiesele Sep 23, 2020
b7b1e02
no need for training data collection
jkiesele Sep 29, 2020
6bafdd2
mostly changes on the container. includes tf probability now. in addi…
jkiesele Oct 26, 2020
6dbcc66
added full sub shuffeling capabilities
jkiesele Oct 26, 2020
e46df75
better TrainData python interface
jkiesele Nov 2, 2020
f1fd792
fix: uproot -> uproot3
andrzejnovak Dec 7, 2020
9794544
feat: add conda recipe
andrzejnovak Dec 7, 2020
c85bfd2
Merge pull request #50 from andrzejnovak/fixuproot
jkiesele Dec 7, 2020
a1bad84
Merge pull request #51 from andrzejnovak/conda
jkiesele Dec 7, 2020
3357c77
update torch geometric
jkiesele Dec 7, 2020
07e7d80
ci: build conda env in GHA
andrzejnovak Dec 7, 2020
b28fbf1
ci: remove conda prefix
andrzejnovak Dec 8, 2020
ed9c543
ci: run conda env for 3.6 and 3.7
andrzejnovak Dec 8, 2020
b4d27d1
ci: fix conda env name
andrzejnovak Dec 8, 2020
60c9b81
ci: list py version
andrzejnovak Dec 8, 2020
b31bf95
ci: allow range in conda
andrzejnovak Dec 8, 2020
1674979
ci: mamba is faster
andrzejnovak Dec 8, 2020
b54a8e9
ci: mamba is faster
andrzejnovak Dec 8, 2020
cf5bdf6
chore: clean up PR
andrzejnovak Dec 8, 2020
2c72868
Merge pull request #52 from andrzejnovak/ci2
jkiesele Dec 9, 2020
190c524
ci: clean up run branch
andrzejnovak Dec 9, 2020
c6c23d5
Merge pull request #53 from andrzejnovak/ci2
jkiesele Dec 9, 2020
359ab26
qkeras in by default
jkiesele Dec 15, 2020
52d52aa
qkeras finally
jkiesele Dec 15, 2020
b2fc513
option to create dummy truth output to satisfy keras requirement of s…
jkiesele Dec 19, 2020
1f6b7f9
just added dash and plotly to standard container
jkiesele Dec 26, 2020
9ba431b
copy function for better python copy of traindata
jkiesele Dec 27, 2020
920a2d1
Update Weighter.py
AlexDeMoor Jan 6, 2021
f0483aa
Merge pull request #54 from AlexDeMoor/master
jkiesele Jan 7, 2021
655c4c7
Cleaning Weighter.py code
Jan 7, 2021
2494c10
Update README.md
emilbols Jan 13, 2021
e546852
Merge pull request #56 from emilbols/patch-1
jkiesele Jan 14, 2021
34bf45c
finally resolved file permission problem
jkiesele Jan 15, 2021
55eaa27
Update Weighter.py for compatibility
Jan 16, 2021
d8457ae
Update Weighter.py for compatibility
Jan 16, 2021
d3aa4a8
Update Weighter.py for compatibility
Jan 16, 2021
5723034
Merge pull request #55 from AlexDeMoor/master
jkiesele Jan 16, 2021
70508d3
Update README.md
jkiesele Jan 27, 2021
298d556
first step of supporting multiple types. not done yet!
jkiesele Feb 5, 2021
b51c0dc
c++ modules new structure compiling. some python bindings and tests s…
jkiesele Feb 6, 2021
3a82391
some fixes
jkiesele Feb 6, 2021
0be7ee2
finally the source files
jkiesele Feb 6, 2021
4ffd6d4
up to traindata, adding tests now
jkiesele Feb 7, 2021
91fa784
so far tests ok
jkiesele Feb 8, 2021
c4a7210
updated CI and readme
jkiesele Feb 8, 2021
e43929b
fixed CI workflow
jkiesele Feb 8, 2021
431e219
another forgotten file
jkiesele Feb 8, 2021
ced0b30
bunch of downstream fixes
jkiesele Feb 8, 2021
965f112
warning message for file format version change
jkiesele Feb 8, 2021
51462bb
you have to specify this now
emilbols Feb 9, 2021
c1dcc63
Merge pull request #57 from emilbols/SmallFix
jkiesele Feb 9, 2021
2b5e45c
another small fix
jkiesele Feb 9, 2021
ce26e82
input names can be specified
jkiesele Feb 11, 2021
d847c7d
create from numpy for simple array easier now
jkiesele Feb 11, 2021
1b29c1f
new traindata append to file. preparation for streamer
jkiesele Mar 9, 2021
f60fcdd
first draft of streamer. more testing needed
jkiesele Mar 15, 2021
abafc45
fixes in example
jkiesele Mar 15, 2021
d24e466
some small fixes, ui improvements
jkiesele Mar 16, 2021
cf451af
new files
jkiesele Mar 16, 2021
6985d41
likely working first version of the trainDataFileStreamer
jkiesele Mar 16, 2021
08c510a
some on the documentation
jkiesele Mar 16, 2021
bd7f6d4
tf 2.4.1 compatible
jkiesele Mar 19, 2021
573361b
some fixes. important to make ragged work in 3.2. consider patch release
jkiesele Mar 20, 2021
6973151
fixes on traindata skim
jkiesele Mar 20, 2021
1b39fa4
prepare for more check functionality
jkiesele Mar 23, 2021
1e08719
added check for nan and inf when creating traindata
jkiesele Apr 8, 2021
ea5b829
removed automatic loss timer
jkiesele May 3, 2021
37ddfc8
Moving to python3
May 17, 2021
a2d4ca8
Merge pull request #58 from chernyavskaya/chernyavskaya-patch-py3
jkiesele May 17, 2021
c8a99f3
fixed subpackage description
jkiesele Jun 1, 2021
fc14f0a
Merge branch 'master' of https://github.com/DL4Jets/DeepJetCore
jkiesele Jun 1, 2021
e75fcfe
new containers
jkiesele Jun 12, 2021
676d375
more options during prediction
jkiesele Jun 12, 2021
0f65c36
tf fix
jkiesele Jun 15, 2021
4f6a4c7
some convenient packages
jkiesele Jun 15, 2021
a94a411
better warning message
jkiesele Jun 15, 2021
2c095ae
new docker file
jkiesele Jun 25, 2021
0894ab2
updated readme, removed references to cernbox
jkiesele Jun 30, 2021
ad92f56
restructured readme a bit
jkiesele Jun 30, 2021
24295a8
fixed inconsistent function naming
jkiesele Jul 6, 2021
f5bd7b4
some clean up
jkiesele Jul 7, 2021
1ee6647
added dictionary support for data generator and hls4ml to container
jkiesele Jul 14, 2021
eb2d457
some hls4ml stuff and fixed issue with latest cuda container
jkiesele Jul 28, 2021
b9158d4
sanity checks for row splits
jkiesele Jul 28, 2021
ee11361
improved pipeline interface
jkiesele Dec 18, 2021
8acb04c
test in docker file
jkiesele Dec 18, 2021
9c24e68
bugfix
jkiesele Dec 21, 2021
fa79f5e
new metric plotting callback
jkiesele Dec 21, 2021
dfd24d0
more functionality
jkiesele Dec 22, 2021
1167d07
make cern krb5 config default
jkiesele Dec 27, 2021
00e945d
publish option
jkiesele Dec 28, 2021
add6d7c
small build order changes and build script
jkiesele Dec 28, 2021
c2ae285
added give up counter
jkiesele Jan 3, 2022
035b44e
small update
jkiesele Jan 4, 2022
88b5535
printout added
jkiesele Jan 4, 2022
492f55a
small record first addition
jkiesele Jan 5, 2022
59f6388
extended callbacks and started some import clean up
jkiesele Jan 9, 2022
2afa7a3
summary print for eager models where build does not work
jkiesele Jan 10, 2022
7a714e0
direct traindata output with cast supported
jkiesele Jan 13, 2022
2216db8
auto casting in data collection for data generator
jkiesele Jan 14, 2022
36e979a
better support of eager models
jkiesele Jan 14, 2022
da04b6c
reduce clutter by making directory
jkiesele Jan 15, 2022
bcc95cc
fix for non serialisable models
jkiesele Jan 18, 2022
a112aff
try for publish
jkiesele Jan 20, 2022
a5df438
bugfix on takeweightsfrom option
jkiesele Jan 23, 2022
e3628c8
gpu conversion option and some clean up. ready to integrate djcdata
jkiesele Jul 23, 2022
172e829
setup for auto builds on cern machines
jkiesele Jul 24, 2022
b9e6998
test auto builds
jkiesele Jul 24, 2022
b68954c
chmod
jkiesele Jul 24, 2022
b01fcee
Merge branch 'master' of https://github.com/DL4Jets/DeepJetCore
jkiesele Jul 24, 2022
efd5548
arg parsing
jkiesele Jul 24, 2022
558bbc2
Merge branch 'master' of https://github.com/DL4Jets/DeepJetCore
jkiesele Jul 24, 2022
7777195
more auto build checks
jkiesele Jul 24, 2022
6da427b
auto build script
jkiesele Jul 24, 2022
7f881d6
add logs
jkiesele Jul 24, 2022
c54d95b
emails
jkiesele Jul 24, 2022
d4c8af9
removing dry run
jkiesele Jul 24, 2022
7698716
some more docu update torch geo
jkiesele Jul 24, 2022
d07fb21
fix
jkiesele Jul 24, 2022
784f4c8
test
jkiesele Jul 24, 2022
20ee8c1
fixes
jkiesele Jul 24, 2022
0db9527
last part of auto build
jkiesele Jul 24, 2022
f00bc02
test auto build commit
jkiesele Jul 24, 2022
fe35f62
more auto build tests
jkiesele Jul 24, 2022
98ba86f
force auto build
jkiesele Jul 24, 2022
f26ca8f
revert to tf2.8 cuda 11.2
jkiesele Jul 24, 2022
9b3422b
fixed form
jkiesele Jul 24, 2022
73e4913
updated torch cuda
jkiesele Jul 24, 2022
695f5c3
torch fix
jkiesele Jul 24, 2022
136d811
revert to TF 2.4
jkiesele Jul 24, 2022
abe1a95
torch first to play more easily with TF version
jkiesele Jul 24, 2022
96c063e
fixed back cusolver symlink for tf 2.4
jkiesele Jul 24, 2022
e4a6ccc
small tfp change
jkiesele Jul 25, 2022
a3f9901
removing some old obsoloete tests
jkiesele Jul 26, 2022
823efe9
revert to cuda 11.2.0
jkiesele Jul 27, 2022
91490a4
TF2.5
jkiesele Jul 28, 2022
5a0d7e3
another try with TF2.5.3 - there are quite some issues with TF builds…
jkiesele Jul 29, 2022
7ed7b2e
gcc switch
jkiesele Jul 29, 2022
659452b
try
jkiesele Jul 29, 2022
50df569
try
jkiesele Jul 29, 2022
812e0e3
g++7
jkiesele Jul 29, 2022
ee034ad
makefile back to py3.6
jkiesele Jul 29, 2022
b72942d
changes for c++17
jkiesele Jul 29, 2022
70dac96
r3.3.0 commit
jkiesele Jul 29, 2022
71c9c96
small fix
jkiesele Jul 29, 2022
4e331c5
yaml
jkiesele Jul 29, 2022
bfd34de
fix
jkiesele Jul 29, 2022
8aa2152
fix for single process conversion
jkiesele Aug 1, 2022
e7a01e1
just more convenient ordering
jkiesele Aug 1, 2022
b8a8810
auto build fix
jkiesele Aug 1, 2022
43646ae
added hist
jkiesele Aug 15, 2022
77e535b
better error messages for custom object import
jkiesele Dec 7, 2022
a0054e7
better printout
jkiesele Dec 7, 2022
2cfe450
Update README.md
jkiesele May 24, 2023
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
126 changes: 126 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: CI/CD

on:
push:
branches:
- 'master'
pull_request:
# Run daily at 0:01 UTC
schedule:
- cron: '1 0 * * *'

jobs:
test:
name: "🐍 ${{ matrix.python-version }} • ${{ matrix.runs-on }}"
runs-on: ${{ matrix.runs-on }}
strategy:
matrix:
# just one for now
runs-on: [ubuntu-latest]
python-version: [3.6, 3.7]

defaults:
run:
shell: "bash -l {0}"

steps:
- uses: actions/checkout@master

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: 'Setup conda env'
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
mamba-version: "*"
channels: conda-forge,defaults
channel-priority: true
auto-activate-base: false
environment-file: conda_env.yml
activate-environment: DJC2

- name: "Check conda env"
run: |
conda env list
conda info
conda list
which python
python -V

- name: Set env vars 1
run: |
# normally one would `source docker_env.sh` but GHA can't do this
# It's not possible to chain these - an exported env var only becomes available in next step
echo "DEEPJETCORE=$( pwd -P)" >> $GITHUB_ENV
echo "PATH=$( pwd -P)/bin:$PATH" >> $GITHUB_ENV
echo "PYTHONPATH=$( pwd -P)/../:$PYTHONPATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$( pwd -P)/compiled/" >> $GITHUB_ENV
# just hardcode it
echo "PYTHONPATH=/home/runner/work/DeepJetCore/DeepJetCore/bin:/home/runner/work/DeepJetCore/DeepJetCore:/home/runner/work/DeepJetCore:$PYTHONPATH" >> $GITHUB_ENV

- name: Check env vars 1
run: |
echo "DEEPJETCORE"
echo $DEEPJETCORE
echo "PATH"
echo $PATH
echo "PYTHONPATH"
echo $PYTHONPATH
echo "LD_LIBRARY_PATH"
echo $LD_LIBRARY_PATH

- name: Compile
run: |
cd $DEEPJETCORE/compiled
make -f Makefile_conda -j4

- name: "Unit tests"
run: |
cd $DEEPJETCORE/testing/unit
python test.py
cd $DEEPJETCORE

- name: Create subpackage
run: |
python bin/createSubpackage.py --data here

- name: Set env vars 2
run: |
# normally one would `source env.sh` but GHA can't do this
# It's not possible to chain these - an exported env var only becomes available in next step
echo "DEEPJETCORE_SUBPACKAGE=$DEEPJETCORE/here" >> $GITHUB_ENV
echo "PATH=$HERE/scripts:$PATH" >> $GITHUB_ENV
echo "LD_LIBRARY_PATH=$HERE/modules/compiled:$LD_LIBRARY_PATH" >> $GITHUB_ENV
# just hardcode it
echo "PYTHONPATH=/home/runner/work/DeepJetCore/DeepJetCore/here/modules:/home/runner/work/DeepJetCore/DeepJetCore/here/modules/datastructures:/home/runner/work/DeepJetCore/DeepJetCore/here/modules/compiled:$PYTHONPATH" >> $GITHUB_ENV

- name: Check env vars 2
run: |
echo "DEEPJETCORE_SUBPACKAGE"
echo $DEEPJETCORE_SUBPACKAGE
echo "PYTHONPATH"
echo $PYTHONPATH
echo "PATH"
echo $PATH
echo "LD_LIBRARY_PATH"
echo $LD_LIBRARY_PATH


- name: Convert files
run: |
cd $DEEPJETCORE
python bin/convertFromSource.py -i here/example_data/train_files.txt -o here/dctrain -c TrainData_example

- name: "Run training"
run: |
# cd $DEEPJETCORE
python here/Train/training_example.py here/dctrain/dataCollection.djcdc here/training

- name: "Run eval"
run: |
predict.py here/training/KERAS_model.h5 here/training/trainsamples.djcdc here/example_data/test_files.txt here/out_predict


5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ __pycache__
*.csv
*.root
*.json
.DS_Store
#*.*#
build/
*.egg-info/
bin/make_example_data_overlap

163 changes: 163 additions & 0 deletions DJCLayers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@

djc_global_layers_list={}

from keras.layers import Layer
import tensorflow as tf



class StopGradient(Layer):
def __init__(self, **kwargs):
super(StopGradient, self).__init__(**kwargs)

def compute_output_shape(self, input_shape):
return input_shape

def call(self, inputs):
return tf.stop_gradient(inputs)

djc_global_layers_list['StopGradient']=StopGradient

class SelectFeatures(Layer):
def __init__(self, index_left, index_right, **kwargs):
super(SelectFeatures, self).__init__(**kwargs)
self.index_left=index_left
self.index_right=index_right

def compute_output_shape(self, input_shape):
return input_shape[:-1] + (self.index_right-self.index_left,)

def call(self, inputs):

return inputs[...,self.index_left:self.index_right]

def get_config(self):
config = {'index_left': self.index_left,'index_right': self.index_right}
base_config = super(SelectFeatures, self).get_config()
return dict(list(base_config.items()) + list(config.items() ))


djc_global_layers_list['SelectFeatures']=SelectFeatures


class ScalarMultiply(Layer):
def __init__(self, factor, **kwargs):
super(ScalarMultiply, self).__init__(**kwargs)
self.factor=factor

def compute_output_shape(self, input_shape):
return input_shape

def call(self, inputs):
return inputs*self.factor

def get_config(self):
config = {'factor': self.factor}
base_config = super(ScalarMultiply, self).get_config()
return dict(list(base_config.items()) + list(config.items() ))


djc_global_layers_list['ScalarMultiply']=ScalarMultiply

class Print(Layer):
def __init__(self, message, **kwargs):
super(Print, self).__init__(**kwargs)
self.message=message

def compute_output_shape(self, input_shape):
return input_shape

def call(self, inputs):
return tf.Print(inputs,[inputs],self.message,summarize=300)

def get_config(self):
config = {'message': self.message}
base_config = super(Print, self).get_config()
return dict(list(base_config.items()) + list(config.items() ))


djc_global_layers_list['Print']=Print

### the following ones should go to DeepJetCore

class ReplaceByNoise(Layer):
def __init__(self, **kwargs):
super(ReplaceByNoise, self).__init__(**kwargs)

def compute_output_shape(self, input_shape):
return input_shape

def call(self, inputs):
return tf.random_normal(shape=tf.shape(inputs),
mean=0.0,
stddev=1.0,
dtype='float32')


def get_config(self):
base_config = super(ReplaceByNoise, self).get_config()
return dict(list(base_config.items()))


djc_global_layers_list['ReplaceByNoise']=ReplaceByNoise



class FeedForward(Layer):
def __init__(self, **kwargs):
super(FeedForward, self).__init__(**kwargs)

def compute_output_shape(self, input_shape):
return input_shape

def call(self, inputs):
return 1.*inputs


def get_config(self):
base_config = super(FeedForward, self).get_config()
return dict(list(base_config.items()))


djc_global_layers_list['FeedForward']=FeedForward


class Clip(Layer):
def __init__(self, min, max , **kwargs):
super(Clip, self).__init__(**kwargs)
self.min=min
self.max=max

def compute_output_shape(self, input_shape):
return input_shape

def call(self, inputs):
return tf.clip_by_value(inputs, self.min, self.max)

def get_config(self):
config = {'min': self.min, 'max': self.max}
base_config = super(Clip, self).get_config()
return dict(list(base_config.items()) + list(config.items() ))

djc_global_layers_list['Clip']=Clip


class ReduceSumEntirely(Layer):
def __init__(self, **kwargs):
super(ReduceSumEntirely, self).__init__(**kwargs)


def compute_output_shape(self, input_shape):
return (input_shape[0],1)

def call(self, inputs):
red_axes=(inputs.shape[1:]).as_list()
red_axes = [i+1 for i in range(len(red_axes))]
return tf.expand_dims(tf.reduce_sum(inputs,axis=red_axes),axis=1)

def get_config(self):
base_config = super(ReduceSumEntirely, self).get_config()
return dict(list(base_config.items()))


djc_global_layers_list['ReduceSumEntirely']=ReduceSumEntirely
11 changes: 11 additions & 0 deletions DJCLosses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

djc_global_loss_list = {}

import tensorflow as tf

def dummy_loss(truth, pred):
#t = tf.Print(truth,[truth],'truth ')
#p = tf.Print(pred,[pred],'pred ')
return (tf.reduce_mean(truth)-tf.reduce_mean(pred))**2

djc_global_loss_list['dummy_loss']=dummy_loss
Loading