Skip to content
Snippets Groups Projects
Commit 73829ffe authored by Engin Eren's avatar Engin Eren
Browse files

Merge branch 'test' of ssh://gitlab.cern.ch:7999/eneren/pytorchjob into test

parents cc4df23a 0ea555f9
No related branches found
No related tags found
1 merge request!3Test
Pipeline #3899325 passed
%% Cell type:code id: tags:
``` python
import torch
import torch.nn as nn
import sys
sys.path.append('/home/jovyan/pytorchjob')
from models.generator import DCGAN_G
from torch.autograd import Variable
import interactive.functions as F
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import h5py
```
%% Cell type:code id: tags:
``` python
## G4
f = h5py.File('/eos/user/e/eneren/run_prod20k_40GeVp2/pion-shower_40.hdf5', 'r')
f40 = h5py.File('/eos/user/e/eneren/run_prod20k_40GeVp2/pion-shower_40.hdf5', 'r')
f50 = h5py.File('/eos/user/e/eneren/scratch/50GeV75k.hdf5', 'r')
```
%% Output
%% Cell type:code id: tags:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-3-e9542526b0da> in <module>
1 ## G4
----> 2 f = h5py.File('/eos/user/e/eneren/run_prod20k_40GeVp2/pion-shower_40.hdf5', 'r')
/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py in __init__(self, name, mode, driver, libver, userblock_size, swmr, rdcc_nslots, rdcc_nbytes, rdcc_w0, track_order, **kwds)
406 fid = make_fid(name, mode, userblock_size,
407 fapl, fcpl=make_fcpl(track_order=track_order),
--> 408 swmr=swmr)
409
410 if isinstance(libver, tuple):
/usr/local/lib/python3.6/dist-packages/h5py/_hl/files.py in make_fid(name, mode, userblock_size, fapl, fcpl, swmr)
171 if swmr and swmr_support:
172 flags |= h5f.ACC_SWMR_READ
--> 173 fid = h5f.open(name, flags, fapl=fapl)
174 elif mode == 'r+':
175 fid = h5f.open(name, h5f.ACC_RDWR, fapl=fapl)
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/_objects.pyx in h5py._objects.with_phil.wrapper()
h5py/h5f.pyx in h5py.h5f.open()
OSError: Unable to open file (unable to open file: name = '/eos/user/e/eneren/run_prod20k_40GeVp2/pion-shower_40.hdf5', errno = 13, error message = 'Permission denied', flags = 0, o_flags = 0)
``` python
showers50 = f50['ecal/layers'][:1000]
showers40 = f40['ecal/layers'][:1000]
```
%% Cell type:code id: tags:
``` python
showers = f['ecal/layers'][:]
showers = {
'50': showers50,
'40': showers40
}
```
%% Cell type:code id: tags:
``` python
ngf = 32
nz=100
mGen = DCGAN_G(ngf, nz)
mGen = nn.parallel.DataParallel(mGen)
exp='wganv1'
batch_size = 1000
for eph in range(60,63):
gen_checkpoint = torch.load('/eos/user/e/eneren/experiments/' + exp + "_generator_"+ str(eph) + ".pt", map_location=torch.device('cpu'))
for eph in range(251,301):
gen_checkpoint = torch.load('/eos/user/e/eneren/experiments/' + exp + "_generator_"+ str(eph) + ".pt", map_location=torch.device('cuda'))
mGen.load_state_dict(gen_checkpoint['model_state_dict'])
mGen.eval()
Tensor = torch.FloatTensor
Tensor = torch.cuda.FloatTensor
z = Variable(Tensor(np.random.uniform(-1, 1, (batch_size, nz, 1, 1, 1))))
elabel = torch.from_numpy(np.random.uniform(40, 40, (batch_size,1,1,1,1))).float()
fake_dataG = mGen(z,elabel).detach()
esumFake = F.getTotE(fake_dataG.numpy(), 30, 30, 30)
esumReal = F.getTotE(showers, 30, 30, 30)
JSD = F.jsdHist(esumReal, esumFake, 50, 0, 100, eph, debug=True)
print ('Epoch {}: '.format(eph), JSD)
jsd = []
for e in [40, 50]:
enp = torch.from_numpy(np.random.uniform(e, e, (batch_size,1,1,1,1))).float()
fake_data = mGen(z,enp).detach()
esumFake = F.getTotE(fake_data.cpu().numpy(), 30, 30, 30)
esumReal = F.getTotE(showers[str(e)], 30, 30, 30)
jsd.append(F.jsdHist(esumReal, esumFake, 50, 0, 100, eph, debug=False))
print ('Epoch {}: '.format(eph), jsd)
#F.plot_image2D(fake_dataG)
```
%% Output
---------------------------------------------------------------------------
PermissionError Traceback (most recent call last)
<ipython-input-4-4d3890daf5c7> in <module>
8
9 for eph in range(60,63):
---> 10 gen_checkpoint = torch.load('/eos/user/e/eneren/experiments/' + exp + "_generator_"+ str(eph) + ".pt", map_location=torch.device('cpu'))
11 mGen.load_state_dict(gen_checkpoint['model_state_dict'])
12 mGen.eval()
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
577 pickle_load_args['encoding'] = 'utf-8'
578
--> 579 with _open_file_like(f, 'rb') as opened_file:
580 if _is_zipfile(opened_file):
581 # The zipfile reader is going to advance the current file position.
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in _open_file_like(name_or_buffer, mode)
228 def _open_file_like(name_or_buffer, mode):
229 if _is_path(name_or_buffer):
--> 230 return _open_file(name_or_buffer, mode)
231 else:
232 if 'w' in mode:
/usr/local/lib/python3.6/dist-packages/torch/serialization.py in __init__(self, name, mode)
209 class _open_file(_opener):
210 def __init__(self, name, mode):
--> 211 super(_open_file, self).__init__(open(name, mode))
212
213 def __exit__(self, *args):
PermissionError: [Errno 13] Permission denied: '/eos/user/e/eneren/experiments/wganv1_generator_60.pt'
Epoch 251: [0.3804679251946886, 0.34817149733098474]
Epoch 252: [0.46051294878083926, 0.338569981047804]
Epoch 253: [0.49756609463285095, 0.28872701740420126]
Epoch 254: [0.5294431896884374, 0.33102840750614887]
Epoch 255: [0.5104405441541784, 0.32231291300401893]
Epoch 256: [0.48537347466233505, 0.320526721042005]
Epoch 257: [0.44430318353292403, 0.33754094942412155]
Epoch 258: [0.41426411913761607, 0.3383523881572018]
Epoch 259: [0.4406027102881503, 0.3343011917750107]
Epoch 260: [0.396682637265716, 0.3473503311876263]
Epoch 261: [0.40394391363113635, 0.36565837165899845]
Epoch 262: [0.42483844096641477, 0.32469973222063503]
Epoch 263: [0.4019302446826285, 0.36214573291228813]
Epoch 264: [0.4126153084092838, 0.38613505292409905]
Epoch 265: [0.4165755030129357, 0.3519977789394489]
Epoch 266: [0.3913068204960252, 0.38645762498974795]
Epoch 267: [0.39439823796062096, 0.3708618579692532]
Epoch 268: [0.40663386822619313, 0.37241345442978496]
Epoch 269: [0.3683487445416732, 0.41097496954033574]
Epoch 270: [0.3931176707467255, 0.36655001291434963]
Epoch 271: [0.36265554202525746, 0.38067712153366035]
Epoch 272: [0.36238044571407557, 0.3891110817723188]
Epoch 273: [0.3443907936692471, 0.41633865859471425]
Epoch 274: [0.3754340116921492, 0.3977884345978468]
Epoch 275: [0.3552435525173964, 0.4127042666470706]
Epoch 276: [0.3043411019678306, 0.4198835584501347]
Epoch 277: [0.34320331541360355, 0.3928834088206806]
Epoch 278: [0.31577926421268404, 0.4058244392791663]
Epoch 279: [0.3009843850678768, 0.4373018678372319]
Epoch 280: [0.3273260324046915, 0.4398480157854807]
Epoch 281: [0.30707030715104516, 0.4339921708642802]
Epoch 282: [0.2915953909635101, 0.4176873424583225]
Epoch 283: [0.2924977435537306, 0.43666767755248453]
Epoch 284: [0.2919643384290543, 0.45133477022104457]
Epoch 285: [0.2947872964957196, 0.449896095813128]
Epoch 286: [0.2897446726869525, 0.48724052437850385]
Epoch 287: [0.31118635032181113, 0.4325288883457097]
Epoch 288: [0.2696458856150868, 0.4629579633785893]
Epoch 289: [0.28041806669044533, 0.46011915244113094]
Epoch 290: [0.3074237951720241, 0.46164573769828265]
Epoch 291: [0.28446450303954507, 0.463811909399871]
Epoch 292: [0.2849400618724373, 0.4441966401101374]
Epoch 293: [0.2826640112838286, 0.4795805721176796]
Epoch 294: [0.2825341470608504, 0.4795195996538825]
Epoch 295: [0.2805225945655388, 0.45946307781001905]
Epoch 296: [0.28991007237838295, 0.46572437861315613]
Epoch 297: [0.2668600287706407, 0.5065609989888424]
Epoch 298: [0.3204394091550444, 0.4845860422924739]
Epoch 299: [0.31568750383524585, 0.48608889263931343]
Epoch 300: [0.2956457355782629, 0.48849089405017004]
%% Cell type:code id: tags:
``` python
fake_dataG.shape
```
%% Cell type:code id: tags:
``` python
F.getTotE(showers, 30, 30, 30)
F.plot_image2D(fake_dataG)
```
%% Cell type:code id: tags:
``` python
```
......
......@@ -70,7 +70,7 @@ def jsdHist(data_real, data_fake, nbins, minE, maxE, eph, debug=False):
range=[minE, maxE])
pSEb = axSE.hist(data_fake, bins=nbins,
weights=np.ones_like(data_fake)/(float(len(data_fake))),
histtype='step', color='black',
histtype='step', color='red',
range=[minE, maxE])
frq1 = pSEa[0]
......@@ -79,8 +79,10 @@ def jsdHist(data_real, data_fake, nbins, minE, maxE, eph, debug=False):
JSD = dist.jensenshannon(frq1, frq2)
if (debug):
plt.savefig('./jsd/esum40_'+str(eph)+'.png')
plt.savefig('./jsd/esum_'+str(eph)+'.png')
plt.close()
if len(frq1) != len(frq2):
print('ERROR JSD: Histogram bins are not matching!!')
return JSD
......
......@@ -37,7 +37,7 @@ spec:
command: [sh, -c]
args:
- cp /secret/krb-secret-vol/krb5cc_1000 /tmp/krb5cc_0 && chmod 600 /tmp/krb5cc_0
&& python -u wgan.py --backend nccl --epochs 100 --exp wganv1 --chpt --chpt_eph 150 --lrGen 0.00001 --ncrit 5;
&& python -u wgan.py --backend nccl --epochs 50 --exp wganv1 --chpt --chpt_eph 250 --lrGen 0.00001 --ncrit 5;
volumeMounts:
- name: eos
mountPath: /eos
......@@ -49,7 +49,7 @@ spec:
limits:
nvidia.com/gpu: 1
Worker:
replicas: 2
replicas: 1
restartPolicy: OnFailure
template:
metadata:
......@@ -81,7 +81,7 @@ spec:
command: [sh, -c]
args:
- cp /secret/krb-secret-vol/krb5cc_1000 /tmp/krb5cc_0 && chmod 600 /tmp/krb5cc_0
&& python -u wgan.py --backend nccl --epochs 100 --exp wganv1 --chpt --chpt_eph 150 --lrGen 0.00001 --ncrit 5;
&& python -u wgan.py --backend nccl --epochs 50 --exp wganv1 --chpt --chpt_eph 250 --lrGen 0.00001 --ncrit 5;
volumeMounts:
- name: eos
mountPath: /eos
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment