Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Calo Opt_Nikhil
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Package registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Krishna Nikhil
Calo Opt_Nikhil
Commits
e325f7dc
Commit
e325f7dc
authored
9 months ago
by
Krishna Krishna Nikhil
Browse files
Options
Downloads
Patches
Plain Diff
Update reconstruction.py
parent
c934eea0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/reconstruction.py
+11
-4
11 additions, 4 deletions
modules/reconstruction.py
with
11 additions
and
4 deletions
modules/reconstruction.py
+
11
−
4
View file @
e325f7dc
...
...
@@ -7,12 +7,17 @@
import
torch
import
torch.utils.data
from
torch.utils.data
import
DataLoader
import
json
#a simple reconstruction model, just feed-forward for now
class
Reconstruction
(
torch
.
nn
.
Module
):
def
__init__
(
self
,
n_detector_parameters
,
n_input_parameters
,
n_target_parameters
):
super
(
Reconstruction
,
self
).
__init__
()
with
open
(
'
config.json
'
,
'
r
'
)
as
config_file
:
config
=
json
.
load
(
config_file
)
self
.
n_parameters
=
n_detector_parameters
self
.
preprocess
=
torch
.
nn
.
Sequential
(
...
...
@@ -20,7 +25,8 @@ class Reconstruction(torch.nn.Module):
torch
.
nn
.
ELU
(),
torch
.
nn
.
Linear
(
100
,
100
),
torch
.
nn
.
ELU
(),
torch
.
nn
.
Linear
(
100
,
n_input_parameters
)
torch
.
nn
.
Linear
(
100
,
n_input_parameters
),
torch
.
nn
.
ReLU
()
)
# take into account that
self
.
layers
=
torch
.
nn
.
Sequential
(
...
...
@@ -38,7 +44,7 @@ class Reconstruction(torch.nn.Module):
# some placeholders for a simpler training loop
self
.
optimizer
=
torch
.
optim
.
Adam
(
self
.
parameters
(),
lr
=
0.0001
)
self
.
device
=
torch
.
device
(
'
cuda
'
)
self
.
device
=
torch
.
device
(
config
[
"
device
"
])
#
cuda
def
forward
(
self
,
detector_parameters
,
x
):
#concatenate the detector parameters and the input
...
...
@@ -61,7 +67,8 @@ class Reconstruction(torch.nn.Module):
train_loader
=
DataLoader
(
dataset
,
batch_size
=
batch_size
,
shuffle
=
True
)
# set the optimizer
self
.
optimizer
.
lr
=
lr
for
param_group
in
self
.
optimizer
.
param_groups
:
param_group
[
'
lr
'
]
=
lr
self
.
to
(
self
.
device
)
self
.
train
()
for
epoch
in
range
(
n_epochs
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment