foscat 3.0.32__py3-none-any.whl → 3.0.33__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
foscat/FoCUS.py CHANGED
@@ -32,7 +32,7 @@ class FoCUS:
32
32
  mpi_size=1,
33
33
  mpi_rank=0):
34
34
 
35
- self.__version__ = '3.0.32'
35
+ self.__version__ = '3.0.33'
36
36
  # P00 coeff for normalization for scat_cov
37
37
  self.TMPFILE_VERSION=TMPFILE_VERSION
38
38
  self.P1_dic = None
@@ -441,25 +441,37 @@ class FoCUS:
441
441
  return self.X_CNN[nside],self.Y_CNN[nside],self.Z_CNN[nside]
442
442
 
443
443
  # ---------------------------------------------−---------
444
- def healpix_layer_transpose(self,im,ww,indices=None,weights=None):
445
- nside=int(np.sqrt(im.shape[0]//12))
444
+ def healpix_layer_transpose(self,im,ww,indices=None,weights=None,axis=0):
445
+ nside=int(np.sqrt(im.shape[axis]//12))
446
446
  l_kernel=self.KERNELSZ*self.KERNELSZ
447
447
 
448
- if im.shape[1]!=ww.shape[1]:
448
+ if im.shape[1+axis]!=ww.shape[1]:
449
449
  if not self.silent:
450
450
  print('Weights channels should be equal to the input image channels')
451
451
  return -1
452
- tmp=self.healpix_layer(im,ww,indices=indices,weights=weights)
452
+ if axis==1:
453
+ results=[]
454
+
455
+ for k in range(im.shape[0]):
456
+
457
+ tmp=self.healpix_layer(im[k],ww,indices=indices,weights=weights,axis=0)
458
+ tmp=self.backend.bk_reshape(self.up_grade(tmp,2*nside),[12*4*nside**2,ww.shape[2]])
459
+
460
+ results.append(tmp)
461
+
462
+ return self.backend.bk_stack(results,axis=0)
463
+ else:
464
+ tmp=self.healpix_layer(im,ww,indices=indices,weights=weights,axis=axis)
453
465
 
454
- return self.up_grade(tmp,2*nside)
466
+ return self.up_grade(tmp,2*nside)
455
467
 
456
468
  # ---------------------------------------------−---------
457
469
  # ---------------------------------------------−---------
458
- def healpix_layer(self,im,ww,indices=None,weights=None):
459
- nside=int(np.sqrt(im.shape[0]//12))
470
+ def healpix_layer(self,im,ww,indices=None,weights=None,axis=0):
471
+ nside=int(np.sqrt(im.shape[axis]//12))
460
472
  l_kernel=self.KERNELSZ*self.KERNELSZ
461
-
462
- if im.shape[1]!=ww.shape[1]:
473
+
474
+ if im.shape[1+axis]!=ww.shape[1]:
463
475
  if not self.silent:
464
476
  print('Weights channels should be equal to the input image channels')
465
477
  return -1
@@ -474,12 +486,27 @@ class FoCUS:
474
486
  return 0
475
487
 
476
488
  mat=self.backend.bk_SparseTensor(indices,weights,[12*nside*nside*l_kernel,12*nside*nside])
477
-
478
- tmp=self.backend.bk_sparse_dense_matmul(mat,im)
479
-
480
- density=self.backend.bk_reshape(tmp,[12*nside*nside,l_kernel*im.shape[1]])
489
+
490
+ if axis==1:
491
+ results=[]
481
492
 
482
- return self.backend.bk_matmul(density,self.backend.bk_reshape(ww,[l_kernel*im.shape[1],ww.shape[2]]))
493
+ for k in range(im.shape[0]):
494
+
495
+ tmp=self.backend.bk_sparse_dense_matmul(mat,im[k])
496
+
497
+ density=self.backend.bk_reshape(tmp,[12*nside*nside,l_kernel*im.shape[1+axis]])
498
+
499
+ density=self.backend.bk_matmul(density,self.backend.bk_reshape(ww,[l_kernel*im.shape[1+axis],ww.shape[2]]))
500
+
501
+ results.append(self.backend.bk_reshape(density,[1,12*nside**2,ww.shape[2]]))
502
+
503
+ return self.backend.bk_stack(results,axis=0)
504
+ else:
505
+ tmp=self.backend.bk_sparse_dense_matmul(mat,im)
506
+
507
+ density=self.backend.bk_reshape(tmp,[12*nside*nside,l_kernel*im.shape[1]])
508
+
509
+ return self.backend.bk_matmul(density,self.backend.bk_reshape(ww,[l_kernel*im.shape[1],ww.shape[2]]))
483
510
  # ---------------------------------------------−---------
484
511
 
485
512
  # ---------------------------------------------−---------
foscat/GCNN.py CHANGED
@@ -79,15 +79,21 @@ class GCNN:
79
79
  def get_weights(self):
80
80
  return self.x
81
81
 
82
- def eval(self,param,indices=None,weights=None):
82
+ def eval(self,param,indices=None,weights=None,axis=0):
83
83
 
84
84
  x=self.x
85
85
 
86
86
  ww=self.scat_operator.backend.bk_reshape(x[0:self.npar*12*self.in_nside**2*self.chanlist[0]], \
87
87
  [self.npar,12*self.in_nside**2*self.chanlist[0]])
88
-
89
- im=self.scat_operator.backend.bk_matmul(self.scat_operator.backend.bk_reshape(param,[1,self.npar]),ww)
90
- im=self.scat_operator.backend.bk_reshape(im,[12*self.in_nside**2,self.chanlist[0]])
88
+
89
+ if axis==0:
90
+ nval=1
91
+ else:
92
+ nval=param.shape[0]
93
+
94
+ im=self.scat_operator.backend.bk_reshape(param,[nval,self.npar])
95
+ im=self.scat_operator.backend.bk_matmul(im,ww)
96
+ im=self.scat_operator.backend.bk_reshape(im,[nval,12*self.in_nside**2,self.chanlist[0]])
91
97
  im=self.scat_operator.backend.bk_relu(im)
92
98
 
93
99
  nn=self.npar*12*self.chanlist[0]*self.in_nside**2
@@ -96,14 +102,15 @@ class GCNN:
96
102
  [self.KERNELSZ*self.KERNELSZ,self.chanlist[k],self.chanlist[k+1]])
97
103
  nn=nn+self.KERNELSZ*self.KERNELSZ*self.chanlist[k]*self.chanlist[k+1]
98
104
  if indices is None:
99
- im=self.scat_operator.healpix_layer_transpose(im,ww)
105
+ im=self.scat_operator.healpix_layer_transpose(im,ww,axis=1)
100
106
  else:
101
- im=self.scat_operator.healpix_layer_transpose(im,ww,indices=indices[k],weights=weights[k])
107
+ im=self.scat_operator.healpix_layer_transpose(im,ww,indices=indices[k],weights=weights[k],axis=1)
102
108
  im=self.scat_operator.backend.bk_relu(im)
103
-
109
+
104
110
  ww=self.scat_operator.backend.bk_reshape(x[nn:],[self.chanlist[self.nscale],self.n_chan_out])
105
111
  im=self.scat_operator.backend.bk_matmul(im,ww)
106
-
112
+ if axis==0:
113
+ im=self.scat_operator.backend.bk_reshape(im,[im.shape[1],im.shape[2]])
107
114
  return im
108
115
 
109
116
 
foscat/backend.py CHANGED
@@ -253,6 +253,14 @@ class foscat_backend:
253
253
  if self.BACKEND==self.NUMPY:
254
254
  return self.scipy.sparse.coo_matrix((w,(indice[:,0],indice[:,1])),shape=dense_shape)
255
255
 
256
+ def bk_stack(self,list,axis=0):
257
+ if self.BACKEND==self.TENSORFLOW:
258
+ return self.backend.stack(list,axis=axis)
259
+ if self.BACKEND==self.TORCH:
260
+ return self.backend.stack(list,axis=axis)
261
+ if self.BACKEND==self.NUMPY:
262
+ return self.backend.stack(list,axis=axis)
263
+
256
264
  def bk_sparse_dense_matmul(self,smat,mat):
257
265
  if self.BACKEND==self.TENSORFLOW:
258
266
  return self.backend.sparse.sparse_dense_matmul(smat,mat)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: foscat
3
- Version: 3.0.32
3
+ Version: 3.0.33
4
4
  Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
5
5
  Home-page: https://github.com/jmdelouis/FOSCAT
6
6
  Author: Jean-Marc DELOUIS
@@ -1,13 +1,13 @@
1
1
  foscat/CNN.py,sha256=M7i9gdPQvFTPxKySrlaKsCnOXK0iwXBKcQ2FqdPK-JM,4408
2
2
  foscat/CircSpline.py,sha256=610sgsWeZzRXYh7gYEqUmGQVrXoHSaFGKjH5mCdh4jU,1684
3
- foscat/FoCUS.py,sha256=gpLSjh7hLclDvsZDWzZDGjBu4OhmxFTCuxglxaR5LLA,70710
4
- foscat/GCNN.py,sha256=G-M1yqLtqTfT3ddu-6vXhEFPGDgbtcEKVTRajgYHzUs,4026
3
+ foscat/FoCUS.py,sha256=iKHY48ukkB4KCOSaGV03pYmqLCQhU1k7VkB8w_gK0o4,71802
4
+ foscat/GCNN.py,sha256=uaJteFo9DUIYnp0yGj7MeW6z3ZQEHFUBGRBuUhy46yY,4241
5
5
  foscat/GetGPUinfo.py,sha256=c01MFYCk38niYCTp0vX3WP24zVDHIsex-Cu42hc9Q18,724
6
6
  foscat/Softmax.py,sha256=UDc8Kbl0qWfH1bqDDwfLnkxhON7p93ueZ-Qg2oY4Ke4,2874
7
7
  foscat/Spline1D.py,sha256=9oeM8SSHjpfUE5z72YxGt1RVt22vJYM1zhHbNBW8phw,1232
8
8
  foscat/Synthesis.py,sha256=aqV_3Npcl2RQj-wxQ0hDMCo650lrN6YRaMd0fAoCrQ4,12615
9
9
  foscat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
- foscat/backend.py,sha256=qw02rs8yVQsO12SR-SshtekX3ZjXLUAX6o04SiG3Krw,31074
10
+ foscat/backend.py,sha256=XDxxMbtoLbxiiPlQZ83rXgTqXUXNw7-qRXtA5h6UpDI,31400
11
11
  foscat/backend_tens.py,sha256=zEFZ71j0nMNP9_91tz21ZVBTayr75l-sfONOLkJ8DyI,1432
12
12
  foscat/loss_backend_tens.py,sha256=WbGC4vy1pBg_bxUXnlCRiXX9WszN6MaUWUc_lUvZNvQ,1667
13
13
  foscat/loss_backend_torch.py,sha256=Fj_W3VwGgeD79eQ4jOxOmhZ548UKDRUb3JjUo2-gSWM,1755
@@ -19,7 +19,7 @@ foscat/scat_cov1D.py,sha256=1bhzaW-5Pcr1aEPOYIXiwu8KOy38JE0g_Y5PvFzGQs8,60599
19
19
  foscat/scat_cov2D.py,sha256=8_XvC-lOEVUWP9vT3Wx10G_ATeVeh0SdrSWuBV7Xf5k,536
20
20
  foscat/scat_cov_map.py,sha256=ocU2xd41GtJhiU9S3dEv38KfPCvz0tJKY2f8lPxpm5c,2729
21
21
  foscat/scat_cov_map2D.py,sha256=t4llIt7DVIyU1b_u-dJSX4lBr2FhDict8RnNnHpRvHM,2754
22
- foscat-3.0.32.dist-info/METADATA,sha256=hT7P_aLrB3sRXdnQCdYqNxUjSp-B9SQ7fh6J3P5wuvA,1013
23
- foscat-3.0.32.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
24
- foscat-3.0.32.dist-info/top_level.txt,sha256=AGySXBBAlJgb8Tj8af6m_F-aiNg2zNTcybCUPVOKjAg,7
25
- foscat-3.0.32.dist-info/RECORD,,
22
+ foscat-3.0.33.dist-info/METADATA,sha256=sblpIJBAMB9ZYPPPzdpIXqq0B5nmbo_y2JniYuI9LF4,1013
23
+ foscat-3.0.33.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
24
+ foscat-3.0.33.dist-info/top_level.txt,sha256=AGySXBBAlJgb8Tj8af6m_F-aiNg2zNTcybCUPVOKjAg,7
25
+ foscat-3.0.33.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.42.0)
2
+ Generator: bdist_wheel (0.43.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5