foscat 3.7.2__tar.gz → 3.8.0__tar.gz
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-3.7.2/src/foscat.egg-info → foscat-3.8.0}/PKG-INFO +1 -2
- {foscat-3.7.2 → foscat-3.8.0}/pyproject.toml +1 -2
- foscat-3.8.0/src/foscat/BkBase.py +546 -0
- foscat-3.8.0/src/foscat/BkNumpy.py +374 -0
- foscat-3.8.0/src/foscat/BkTensorflow.py +479 -0
- foscat-3.8.0/src/foscat/BkTorch.py +437 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/FoCUS.py +50 -33
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/alm.py +164 -137
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/backend.py +5 -2
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat_cov.py +730 -245
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat_cov2D.py +1 -1
- {foscat-3.7.2 → foscat-3.8.0/src/foscat.egg-info}/PKG-INFO +1 -2
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat.egg-info/SOURCES.txt +4 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat.egg-info/requires.txt +0 -1
- {foscat-3.7.2 → foscat-3.8.0}/LICENSE +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/README.md +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/setup.cfg +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/CNN.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/CircSpline.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/GCNN.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/Softmax.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/Spline1D.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/Synthesis.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/__init__.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/backend_tens.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/loss_backend_tens.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/loss_backend_torch.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat1D.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat2D.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat_cov1D.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat_cov_map.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat/scat_cov_map2D.py +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat.egg-info/dependency_links.txt +0 -0
- {foscat-3.7.2 → foscat-3.8.0}/src/foscat.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: foscat
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.0
|
|
4
4
|
Summary: Generate synthetic Healpix or 2D data using Cross Scattering Transform
|
|
5
5
|
Author-email: Jean-Marc DELOUIS <jean.marc.delouis@ifremer.fr>
|
|
6
6
|
Maintainer-email: Theo Foulquier <theo.foulquier@ifremer.fr>
|
|
@@ -23,7 +23,6 @@ Requires-Dist: imageio
|
|
|
23
23
|
Requires-Dist: imagecodecs
|
|
24
24
|
Requires-Dist: matplotlib
|
|
25
25
|
Requires-Dist: numpy
|
|
26
|
-
Requires-Dist: tensorflow
|
|
27
26
|
Requires-Dist: healpy
|
|
28
27
|
Requires-Dist: spherical
|
|
29
28
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "foscat"
|
|
3
|
-
version = "3.
|
|
3
|
+
version = "3.8.0"
|
|
4
4
|
description = "Generate synthetic Healpix or 2D data using Cross Scattering Transform"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = { text = "BSD-3-Clause" }
|
|
@@ -17,7 +17,6 @@ dependencies = [
|
|
|
17
17
|
"imagecodecs",
|
|
18
18
|
"matplotlib",
|
|
19
19
|
"numpy",
|
|
20
|
-
"tensorflow",
|
|
21
20
|
"healpy",
|
|
22
21
|
"spherical",
|
|
23
22
|
]
|
|
@@ -0,0 +1,546 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
class BackendBase:
|
|
4
|
+
|
|
5
|
+
def __init__(self, name, mpi_rank=0, all_type="float64", gpupos=0, silent=False):
|
|
6
|
+
|
|
7
|
+
self.BACKEND=name
|
|
8
|
+
self.mpi_rank=mpi_rank
|
|
9
|
+
self.all_type=all_type
|
|
10
|
+
self.gpupos=gpupos
|
|
11
|
+
self.silent=silent
|
|
12
|
+
# ---------------------------------------------−---------
|
|
13
|
+
# table use to compute the iso orientation rotation
|
|
14
|
+
self._iso_orient = {}
|
|
15
|
+
self._iso_orient_T = {}
|
|
16
|
+
self._iso_orient_C = {}
|
|
17
|
+
self._iso_orient_C_T = {}
|
|
18
|
+
self._fft_1_orient = {}
|
|
19
|
+
self._fft_1_orient_C = {}
|
|
20
|
+
self._fft_2_orient = {}
|
|
21
|
+
self._fft_2_orient_C = {}
|
|
22
|
+
self._fft_3_orient = {}
|
|
23
|
+
self._fft_3_orient_C = {}
|
|
24
|
+
|
|
25
|
+
def iso_mean(self, x, use_2D=False):
|
|
26
|
+
shape = list(x.shape)
|
|
27
|
+
|
|
28
|
+
i_orient = 2
|
|
29
|
+
if use_2D:
|
|
30
|
+
i_orient = 3
|
|
31
|
+
norient = shape[i_orient]
|
|
32
|
+
|
|
33
|
+
if len(shape) == i_orient + 1:
|
|
34
|
+
return self.bk_reduce_mean(x, -1)
|
|
35
|
+
|
|
36
|
+
if norient not in self._iso_orient:
|
|
37
|
+
self.calc_iso_orient(norient)
|
|
38
|
+
|
|
39
|
+
if self.bk_is_complex(x):
|
|
40
|
+
lmat = self._iso_orient_C[norient]
|
|
41
|
+
else:
|
|
42
|
+
lmat = self._iso_orient[norient]
|
|
43
|
+
|
|
44
|
+
oshape = shape[0]
|
|
45
|
+
for k in range(1, len(shape) - 2):
|
|
46
|
+
oshape *= shape[k]
|
|
47
|
+
|
|
48
|
+
oshape2 = [shape[k] for k in range(0, len(shape) - 1)]
|
|
49
|
+
|
|
50
|
+
return self.bk_reshape(
|
|
51
|
+
self.backend.matmul(self.bk_reshape(x, [oshape, norient * norient]), lmat),
|
|
52
|
+
oshape2,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def fft_ang(self, x, nharm=1, imaginary=False, use_2D=False):
|
|
56
|
+
shape = list(x.shape)
|
|
57
|
+
|
|
58
|
+
i_orient = 2
|
|
59
|
+
if use_2D:
|
|
60
|
+
i_orient = 3
|
|
61
|
+
|
|
62
|
+
norient = shape[i_orient]
|
|
63
|
+
nout = 1 + nharm
|
|
64
|
+
|
|
65
|
+
oshape_1 = shape[0]
|
|
66
|
+
for k in range(1, i_orient):
|
|
67
|
+
oshape_1 *= shape[k]
|
|
68
|
+
oshape_2 = norient
|
|
69
|
+
for k in range(i_orient, len(shape) - 1):
|
|
70
|
+
oshape_2 *= shape[k]
|
|
71
|
+
oshape = [oshape_1, oshape_2]
|
|
72
|
+
|
|
73
|
+
if imaginary:
|
|
74
|
+
nout = 1 + nharm * 2
|
|
75
|
+
|
|
76
|
+
oshape2 = [shape[k] for k in range(0, i_orient)] + [
|
|
77
|
+
nout for k in range(i_orient, len(shape))
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
if (norient, nharm) not in self._fft_1_orient:
|
|
81
|
+
self.calc_fft_orient(norient, nharm, imaginary)
|
|
82
|
+
|
|
83
|
+
if len(shape) == i_orient + 1:
|
|
84
|
+
if self.bk_is_complex(x):
|
|
85
|
+
lmat = self._fft_1_orient_C[(norient, nharm, imaginary)]
|
|
86
|
+
else:
|
|
87
|
+
lmat = self._fft_1_orient[(norient, nharm, imaginary)]
|
|
88
|
+
|
|
89
|
+
if len(shape) == i_orient + 2:
|
|
90
|
+
if self.bk_is_complex(x):
|
|
91
|
+
lmat = self._fft_2_orient_C[(norient, nharm, imaginary)]
|
|
92
|
+
else:
|
|
93
|
+
lmat = self._fft_2_orient[(norient, nharm, imaginary)]
|
|
94
|
+
|
|
95
|
+
if len(shape) == i_orient + 3:
|
|
96
|
+
if self.bk_is_complex(x):
|
|
97
|
+
lmat = self._fft_3_orient_C[(norient, nharm, imaginary)]
|
|
98
|
+
else:
|
|
99
|
+
lmat = self._fft_3_orient[(norient, nharm, imaginary)]
|
|
100
|
+
|
|
101
|
+
return self.bk_reshape(
|
|
102
|
+
self.backend.matmul(self.bk_reshape(x, oshape), lmat), oshape2
|
|
103
|
+
)
|
|
104
|
+
def calc_iso_orient(self, norient):
|
|
105
|
+
tmp = np.zeros([norient * norient, norient])
|
|
106
|
+
for i in range(norient):
|
|
107
|
+
for j in range(norient):
|
|
108
|
+
tmp[j * norient + (j + i) % norient, i] = 0.25
|
|
109
|
+
|
|
110
|
+
self._iso_orient[norient] = self.bk_constant(self.bk_cast(tmp))
|
|
111
|
+
self._iso_orient_T[norient] = self.bk_constant(self.bk_cast(4 * tmp.T))
|
|
112
|
+
self._iso_orient_C[norient] = self.bk_complex(
|
|
113
|
+
self._iso_orient[norient], 0 * self._iso_orient[norient]
|
|
114
|
+
)
|
|
115
|
+
self._iso_orient_C_T[norient] = self.bk_complex(
|
|
116
|
+
self._iso_orient_T[norient], 0 * self._iso_orient_T[norient]
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
def calc_fft_orient(self, norient, nharm, imaginary):
|
|
120
|
+
|
|
121
|
+
x = np.arange(norient) / norient * 2 * np.pi
|
|
122
|
+
|
|
123
|
+
if imaginary:
|
|
124
|
+
tmp = np.zeros([norient, 1 + nharm * 2])
|
|
125
|
+
tmp[:, 0] = 1.0
|
|
126
|
+
for k in range(nharm):
|
|
127
|
+
tmp[:, k * 2 + 1] = np.cos(x * (k + 1))
|
|
128
|
+
tmp[:, k * 2 + 2] = np.sin(x * (k + 1))
|
|
129
|
+
|
|
130
|
+
self._fft_1_orient[(norient, nharm, imaginary)] = self.bk_cast(
|
|
131
|
+
self.bk_constant(tmp)
|
|
132
|
+
)
|
|
133
|
+
self._fft_1_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
|
|
134
|
+
self._fft_1_orient[(norient, nharm, imaginary)],
|
|
135
|
+
0 * self._fft_1_orient[(norient, nharm, imaginary)],
|
|
136
|
+
)
|
|
137
|
+
else:
|
|
138
|
+
tmp = np.zeros([norient, 1 + nharm])
|
|
139
|
+
for k in range(nharm + 1):
|
|
140
|
+
tmp[:, k] = np.cos(x * k)
|
|
141
|
+
|
|
142
|
+
self._fft_1_orient[(norient, nharm, imaginary)] = self.bk_cast(
|
|
143
|
+
self.bk_constant(tmp)
|
|
144
|
+
)
|
|
145
|
+
self._fft_1_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
|
|
146
|
+
self._fft_1_orient[(norient, nharm, imaginary)],
|
|
147
|
+
0 * self._fft_1_orient[(norient, nharm, imaginary)],
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
x = np.repeat(x, norient).reshape(norient, norient)
|
|
151
|
+
|
|
152
|
+
if imaginary:
|
|
153
|
+
tmp = np.zeros([norient, norient, (1 + nharm * 2), (1 + nharm * 2)])
|
|
154
|
+
tmp[:, :, 0, 0] = 1.0
|
|
155
|
+
for k in range(nharm):
|
|
156
|
+
tmp[:, :, k * 2 + 1, 0] = np.cos(x * (k + 1))
|
|
157
|
+
tmp[:, :, k * 2 + 2, 0] = np.sin(x * (k + 1))
|
|
158
|
+
tmp[:, :, 0, k * 2 + 1] = np.cos((x.T) * (k + 1))
|
|
159
|
+
tmp[:, :, 0, k * 2 + 2] = np.sin((x.T) * (k + 1))
|
|
160
|
+
for l_orient in range(nharm):
|
|
161
|
+
tmp[:, :, k * 2 + 1, l_orient * 2 + 1] = np.cos(
|
|
162
|
+
x * (k + 1)
|
|
163
|
+
) * np.cos((x.T) * (l_orient + 1))
|
|
164
|
+
tmp[:, :, k * 2 + 2, l_orient * 2 + 1] = np.sin(
|
|
165
|
+
x * (k + 1)
|
|
166
|
+
) * np.cos((x.T) * (l_orient + 1))
|
|
167
|
+
tmp[:, :, k * 2 + 1, l_orient * 2 + 2] = np.cos(
|
|
168
|
+
x * (k + 1)
|
|
169
|
+
) * np.sin((x.T) * (l_orient + 1))
|
|
170
|
+
tmp[:, :, k * 2 + 2, l_orient * 2 + 2] = np.sin(
|
|
171
|
+
x * (k + 1)
|
|
172
|
+
) * np.sin((x.T) * (l_orient + 1))
|
|
173
|
+
|
|
174
|
+
self._fft_2_orient[(norient, nharm, imaginary)] = self.bk_cast(
|
|
175
|
+
self.bk_constant(
|
|
176
|
+
tmp.reshape(norient * norient, (1 + 2 * nharm) * (1 + 2 * nharm))
|
|
177
|
+
)
|
|
178
|
+
)
|
|
179
|
+
self._fft_2_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
|
|
180
|
+
self._fft_2_orient[(norient, nharm, imaginary)],
|
|
181
|
+
0 * self._fft_2_orient[(norient, nharm, imaginary)],
|
|
182
|
+
)
|
|
183
|
+
else:
|
|
184
|
+
tmp = np.zeros([norient, norient, (1 + nharm), (1 + nharm)])
|
|
185
|
+
|
|
186
|
+
for k in range(nharm + 1):
|
|
187
|
+
for l_orient in range(nharm + 1):
|
|
188
|
+
tmp[:, :, k, l_orient] = np.cos(x * k) * np.cos((x.T) * l_orient)
|
|
189
|
+
|
|
190
|
+
self._fft_2_orient[(norient, nharm, imaginary)] = self.bk_cast(
|
|
191
|
+
self.bk_constant(tmp.reshape(norient * norient, (1 + nharm) * (1 + nharm)))
|
|
192
|
+
)
|
|
193
|
+
self._fft_2_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
|
|
194
|
+
self._fft_2_orient[(norient, nharm, imaginary)],
|
|
195
|
+
0 * self._fft_2_orient[(norient, nharm, imaginary)],
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
x = np.arange(norient) / norient * 2 * np.pi
|
|
199
|
+
xx = np.zeros([norient, norient, norient])
|
|
200
|
+
yy = np.zeros([norient, norient, norient])
|
|
201
|
+
zz = np.zeros([norient, norient, norient])
|
|
202
|
+
for i in range(norient):
|
|
203
|
+
for j in range(norient):
|
|
204
|
+
xx[:, i, j] = x
|
|
205
|
+
yy[i, :, j] = x
|
|
206
|
+
zz[i, j, :] = x
|
|
207
|
+
|
|
208
|
+
if imaginary:
|
|
209
|
+
tmp = np.ones(
|
|
210
|
+
[
|
|
211
|
+
norient,
|
|
212
|
+
norient,
|
|
213
|
+
norient,
|
|
214
|
+
(1 + nharm * 2),
|
|
215
|
+
(1 + nharm * 2),
|
|
216
|
+
(1 + nharm * 2),
|
|
217
|
+
]
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
for k in range(nharm):
|
|
221
|
+
tmp[:, :, :, k * 2 + 1, 0, 0] = np.cos(xx * (k + 1))
|
|
222
|
+
tmp[:, :, :, 0, k * 2 + 1, 0] = np.cos(yy * (k + 1))
|
|
223
|
+
tmp[:, :, :, 0, 0, k * 2 + 1] = np.cos(zz * (k + 1))
|
|
224
|
+
|
|
225
|
+
tmp[:, :, :, k * 2 + 2, 0, 0] = np.sin(xx * (k + 1))
|
|
226
|
+
tmp[:, :, :, 0, k * 2 + 2, 0] = np.sin(yy * (k + 1))
|
|
227
|
+
tmp[:, :, :, 0, 0, k * 2 + 2] = np.sin(zz * (k + 1))
|
|
228
|
+
for l_orient in range(nharm):
|
|
229
|
+
tmp[:, :, :, k * 2 + 1, l_orient * 2 + 1, 0] = np.cos(
|
|
230
|
+
xx * (k + 1)
|
|
231
|
+
) * np.cos(yy * (l_orient + 1))
|
|
232
|
+
tmp[:, :, :, k * 2 + 1, l_orient * 2 + 2, 0] = np.cos(
|
|
233
|
+
xx * (k + 1)
|
|
234
|
+
) * np.sin(yy * (l_orient + 1))
|
|
235
|
+
tmp[:, :, :, k * 2 + 2, l_orient * 2 + 1, 0] = np.sin(
|
|
236
|
+
xx * (k + 1)
|
|
237
|
+
) * np.cos(yy * (l_orient + 1))
|
|
238
|
+
tmp[:, :, :, k * 2 + 2, l_orient * 2 + 2, 0] = np.sin(
|
|
239
|
+
xx * (k + 1)
|
|
240
|
+
) * np.sin(yy * (l_orient + 1))
|
|
241
|
+
|
|
242
|
+
tmp[:, :, :, k * 2 + 1, 0, l_orient * 2 + 1] = np.cos(
|
|
243
|
+
xx * (k + 1)
|
|
244
|
+
) * np.cos(zz * (l_orient + 1))
|
|
245
|
+
tmp[:, :, :, k * 2 + 1, 0, l_orient * 2 + 2] = np.cos(
|
|
246
|
+
xx * (k + 1)
|
|
247
|
+
) * np.sin(zz * (l_orient + 1))
|
|
248
|
+
tmp[:, :, :, k * 2 + 2, 0, l_orient * 2 + 1] = np.sin(
|
|
249
|
+
xx * (k + 1)
|
|
250
|
+
) * np.cos(zz * (l_orient + 1))
|
|
251
|
+
tmp[:, :, :, k * 2 + 2, 0, l_orient * 2 + 2] = np.sin(
|
|
252
|
+
xx * (k + 1)
|
|
253
|
+
) * np.sin(zz * (l_orient + 1))
|
|
254
|
+
|
|
255
|
+
tmp[:, :, :, 0, k * 2 + 1, l_orient * 2 + 1] = np.cos(
|
|
256
|
+
yy * (k + 1)
|
|
257
|
+
) * np.cos(zz * (l_orient + 1))
|
|
258
|
+
tmp[:, :, :, 0, k * 2 + 1, l_orient * 2 + 2] = np.cos(
|
|
259
|
+
yy * (k + 1)
|
|
260
|
+
) * np.sin(zz * (l_orient + 1))
|
|
261
|
+
tmp[:, :, :, 0, k * 2 + 2, l_orient * 2 + 1] = np.sin(
|
|
262
|
+
yy * (k + 1)
|
|
263
|
+
) * np.cos(zz * (l_orient + 1))
|
|
264
|
+
tmp[:, :, :, 0, k * 2 + 2, l_orient * 2 + 2] = np.sin(
|
|
265
|
+
yy * (k + 1)
|
|
266
|
+
) * np.sin(zz * (l_orient + 1))
|
|
267
|
+
|
|
268
|
+
for m in range(nharm):
|
|
269
|
+
tmp[:, :, :, k * 2 + 1, l_orient * 2 + 1, m * 2 + 1] = (
|
|
270
|
+
np.cos(xx * (k + 1))
|
|
271
|
+
* np.cos(yy * (l_orient + 1))
|
|
272
|
+
* np.cos(zz * (m + 1))
|
|
273
|
+
)
|
|
274
|
+
tmp[:, :, :, k * 2 + 1, l_orient * 2 + 1, m * 2 + 2] = (
|
|
275
|
+
np.cos(xx * (k + 1))
|
|
276
|
+
* np.cos(yy * (l_orient + 1))
|
|
277
|
+
* np.sin(zz * (m + 1))
|
|
278
|
+
)
|
|
279
|
+
tmp[:, :, :, k * 2 + 1, l_orient * 2 + 2, m * 2 + 1] = (
|
|
280
|
+
np.cos(xx * (k + 1))
|
|
281
|
+
* np.sin(yy * (l_orient + 1))
|
|
282
|
+
* np.cos(zz * (m + 1))
|
|
283
|
+
)
|
|
284
|
+
tmp[:, :, :, k * 2 + 1, l_orient * 2 + 2, m * 2 + 2] = (
|
|
285
|
+
np.cos(xx * (k + 1))
|
|
286
|
+
* np.sin(yy * (l_orient + 1))
|
|
287
|
+
* np.sin(zz * (m + 1))
|
|
288
|
+
)
|
|
289
|
+
tmp[:, :, :, k * 2 + 2, l_orient * 2 + 1, m * 2 + 1] = (
|
|
290
|
+
np.sin(xx * (k + 1))
|
|
291
|
+
* np.cos(yy * (l_orient + 1))
|
|
292
|
+
* np.cos(zz * (m + 1))
|
|
293
|
+
)
|
|
294
|
+
tmp[:, :, :, k * 2 + 2, l_orient * 2 + 1, m * 2 + 2] = (
|
|
295
|
+
np.sin(xx * (k + 1))
|
|
296
|
+
* np.cos(yy * (l_orient + 1))
|
|
297
|
+
* np.sin(zz * (m + 1))
|
|
298
|
+
)
|
|
299
|
+
tmp[:, :, :, k * 2 + 2, l_orient * 2 + 2, m * 2 + 1] = (
|
|
300
|
+
np.sin(xx * (k + 1))
|
|
301
|
+
* np.sin(yy * (l_orient + 1))
|
|
302
|
+
* np.cos(zz * (m + 1))
|
|
303
|
+
)
|
|
304
|
+
tmp[:, :, :, k * 2 + 2, l_orient * 2 + 2, m * 2 + 2] = (
|
|
305
|
+
np.sin(xx * (k + 1))
|
|
306
|
+
* np.sin(yy * (l_orient + 1))
|
|
307
|
+
* np.sin(zz * (m + 1))
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
self._fft_3_orient[(norient, nharm, imaginary)] = self.bk_cast(
|
|
311
|
+
self.bk_constant(
|
|
312
|
+
tmp.reshape(
|
|
313
|
+
norient * norient * norient,
|
|
314
|
+
(1 + nharm * 2) * (1 + nharm * 2) * (1 + nharm * 2),
|
|
315
|
+
)
|
|
316
|
+
)
|
|
317
|
+
)
|
|
318
|
+
self._fft_3_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
|
|
319
|
+
self._fft_3_orient[(norient, nharm, imaginary)],
|
|
320
|
+
0 * self._fft_3_orient[(norient, nharm, imaginary)],
|
|
321
|
+
)
|
|
322
|
+
else:
|
|
323
|
+
tmp = np.zeros(
|
|
324
|
+
[norient, norient, norient, (1 + nharm), (1 + nharm), (1 + nharm)]
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
for k in range(nharm + 1):
|
|
328
|
+
for l_orient in range(nharm + 1):
|
|
329
|
+
for m in range(nharm + 1):
|
|
330
|
+
tmp[:, :, :, k, l_orient, m] = (
|
|
331
|
+
np.cos(xx * k) * np.cos(yy * l_orient) * np.cos(zz * m)
|
|
332
|
+
)
|
|
333
|
+
|
|
334
|
+
self._fft_3_orient[(norient, nharm, imaginary)] = self.bk_cast(
|
|
335
|
+
self.bk_constant(
|
|
336
|
+
tmp.reshape(
|
|
337
|
+
norient * norient * norient,
|
|
338
|
+
(1 + nharm) * (1 + nharm) * (1 + nharm),
|
|
339
|
+
)
|
|
340
|
+
)
|
|
341
|
+
)
|
|
342
|
+
self._fft_3_orient_C[(norient, nharm, imaginary)] = self.bk_complex(
|
|
343
|
+
self._fft_3_orient[(norient, nharm, imaginary)],
|
|
344
|
+
0 * self._fft_3_orient[(norient, nharm, imaginary)],
|
|
345
|
+
)
|
|
346
|
+
|
|
347
|
+
# ---------------------------------------------−---------
|
|
348
|
+
# -- BACKEND DEFINITION --
|
|
349
|
+
# ---------------------------------------------−---------
|
|
350
|
+
def bk_SparseTensor(self, indice, w, dense_shape=[]):
|
|
351
|
+
raise NotImplementedError("This is an abstract class.")
|
|
352
|
+
|
|
353
|
+
def bk_stack(self, list, axis=0):
|
|
354
|
+
raise NotImplementedError("This is an abstract class.")
|
|
355
|
+
|
|
356
|
+
def bk_sparse_dense_matmul(self, smat, mat):
|
|
357
|
+
raise NotImplementedError("This is an abstract class.")
|
|
358
|
+
|
|
359
|
+
def conv2d(self, x, w, strides=[1, 1, 1, 1], padding="SAME"):
|
|
360
|
+
raise NotImplementedError("This is an abstract class.")
|
|
361
|
+
|
|
362
|
+
def conv1d(self, x, w, strides=[1, 1, 1], padding="SAME"):
|
|
363
|
+
raise NotImplementedError("This is an abstract class.")
|
|
364
|
+
|
|
365
|
+
def bk_threshold(self, x, threshold, greater=True):
|
|
366
|
+
raise NotImplementedError("This is an abstract class.")
|
|
367
|
+
|
|
368
|
+
def bk_maximum(self, x1, x2):
|
|
369
|
+
raise NotImplementedError("This is an abstract class.")
|
|
370
|
+
|
|
371
|
+
def bk_device(self, device_name):
|
|
372
|
+
raise NotImplementedError("This is an abstract class.")
|
|
373
|
+
|
|
374
|
+
def bk_ones(self, shape, dtype=None):
|
|
375
|
+
raise NotImplementedError("This is an abstract class.")
|
|
376
|
+
|
|
377
|
+
def bk_conv1d(self, x, w):
|
|
378
|
+
raise NotImplementedError("This is an abstract class.")
|
|
379
|
+
|
|
380
|
+
def bk_flattenR(self, x):
|
|
381
|
+
raise NotImplementedError("This is an abstract class.")
|
|
382
|
+
|
|
383
|
+
def bk_flatten(self, x):
|
|
384
|
+
raise NotImplementedError("This is an abstract class.")
|
|
385
|
+
|
|
386
|
+
def bk_flatten(self, x):
|
|
387
|
+
raise NotImplementedError("This is an abstract class.")
|
|
388
|
+
|
|
389
|
+
def bk_size(self, x):
|
|
390
|
+
raise NotImplementedError("This is an abstract class.")
|
|
391
|
+
|
|
392
|
+
def bk_resize_image(self, x, shape):
|
|
393
|
+
raise NotImplementedError("This is an abstract class.")
|
|
394
|
+
|
|
395
|
+
def bk_L1(self, x):
|
|
396
|
+
raise NotImplementedError("This is an abstract class.")
|
|
397
|
+
|
|
398
|
+
def bk_square_comp(self, x):
|
|
399
|
+
raise NotImplementedError("This is an abstract class.")
|
|
400
|
+
|
|
401
|
+
def bk_reduce_sum(self, data, axis=None):
|
|
402
|
+
raise NotImplementedError("This is an abstract class.")
|
|
403
|
+
|
|
404
|
+
def bk_reduce_mean(self, data, axis=None):
|
|
405
|
+
raise NotImplementedError("This is an abstract class.")
|
|
406
|
+
|
|
407
|
+
def bk_reduce_min(self, data, axis=None):
|
|
408
|
+
raise NotImplementedError("This is an abstract class.")
|
|
409
|
+
|
|
410
|
+
def bk_random_seed(self, value):
|
|
411
|
+
raise NotImplementedError("This is an abstract class.")
|
|
412
|
+
|
|
413
|
+
def bk_random_uniform(self, shape):
|
|
414
|
+
raise NotImplementedError("This is an abstract class.")
|
|
415
|
+
|
|
416
|
+
def bk_reduce_std(self, data, axis=None):
|
|
417
|
+
raise NotImplementedError("This is an abstract class.")
|
|
418
|
+
|
|
419
|
+
def bk_sqrt(self, data):
|
|
420
|
+
raise NotImplementedError("This is an abstract class.")
|
|
421
|
+
|
|
422
|
+
def bk_abs(self, data):
|
|
423
|
+
raise NotImplementedError("This is an abstract class.")
|
|
424
|
+
|
|
425
|
+
def bk_is_complex(self, data):
|
|
426
|
+
raise NotImplementedError("This is an abstract class.")
|
|
427
|
+
|
|
428
|
+
def bk_distcomp(self, data):
|
|
429
|
+
raise NotImplementedError("This is an abstract class.")
|
|
430
|
+
|
|
431
|
+
def bk_norm(self, data):
|
|
432
|
+
raise NotImplementedError("This is an abstract class.")
|
|
433
|
+
|
|
434
|
+
def bk_square(self, data):
|
|
435
|
+
raise NotImplementedError("This is an abstract class.")
|
|
436
|
+
|
|
437
|
+
def bk_log(self, data):
|
|
438
|
+
raise NotImplementedError("This is an abstract class.")
|
|
439
|
+
|
|
440
|
+
def bk_matmul(self, a, b):
|
|
441
|
+
raise NotImplementedError("This is an abstract class.")
|
|
442
|
+
|
|
443
|
+
def bk_tensor(self, data):
|
|
444
|
+
raise NotImplementedError("This is an abstract class.")
|
|
445
|
+
|
|
446
|
+
def bk_shape_tensor(self, shape):
|
|
447
|
+
raise NotImplementedError("This is an abstract class.")
|
|
448
|
+
|
|
449
|
+
def bk_complex(self, real, imag):
|
|
450
|
+
raise NotImplementedError("This is an abstract class.")
|
|
451
|
+
|
|
452
|
+
def bk_exp(self, data):
|
|
453
|
+
raise NotImplementedError("This is an abstract class.")
|
|
454
|
+
|
|
455
|
+
def bk_min(self, data):
|
|
456
|
+
raise NotImplementedError("This is an abstract class.")
|
|
457
|
+
|
|
458
|
+
def bk_argmin(self, data):
|
|
459
|
+
raise NotImplementedError("This is an abstract class.")
|
|
460
|
+
|
|
461
|
+
def bk_tanh(self, data):
|
|
462
|
+
raise NotImplementedError("This is an abstract class.")
|
|
463
|
+
|
|
464
|
+
def bk_max(self, data):
|
|
465
|
+
raise NotImplementedError("This is an abstract class.")
|
|
466
|
+
|
|
467
|
+
def bk_argmax(self, data):
|
|
468
|
+
raise NotImplementedError("This is an abstract class.")
|
|
469
|
+
|
|
470
|
+
def bk_reshape(self, data, shape):
|
|
471
|
+
raise NotImplementedError("This is an abstract class.")
|
|
472
|
+
|
|
473
|
+
def bk_repeat(self, data, nn, axis=0):
|
|
474
|
+
raise NotImplementedError("This is an abstract class.")
|
|
475
|
+
|
|
476
|
+
def bk_tile(self, data, nn, axis=0):
|
|
477
|
+
raise NotImplementedError("This is an abstract class.")
|
|
478
|
+
|
|
479
|
+
def bk_roll(self, data, nn, axis=0):
|
|
480
|
+
raise NotImplementedError("This is an abstract class.")
|
|
481
|
+
|
|
482
|
+
def bk_expand_dims(self, data, axis=0):
|
|
483
|
+
raise NotImplementedError("This is an abstract class.")
|
|
484
|
+
|
|
485
|
+
def bk_transpose(self, data, thelist):
|
|
486
|
+
raise NotImplementedError("This is an abstract class.")
|
|
487
|
+
|
|
488
|
+
def bk_concat(self, data, axis=None):
|
|
489
|
+
raise NotImplementedError("This is an abstract class.")
|
|
490
|
+
|
|
491
|
+
def bk_zeros(self, shape, dtype=None):
|
|
492
|
+
raise NotImplementedError("This is an abstract class.")
|
|
493
|
+
|
|
494
|
+
def bk_gather(self, data, idx):
|
|
495
|
+
raise NotImplementedError("This is an abstract class.")
|
|
496
|
+
|
|
497
|
+
def bk_reverse(self, data, axis=0):
|
|
498
|
+
raise NotImplementedError("This is an abstract class.")
|
|
499
|
+
|
|
500
|
+
def bk_fft(self, data):
|
|
501
|
+
raise NotImplementedError("This is an abstract class.")
|
|
502
|
+
|
|
503
|
+
def bk_fftn(self, data,dim=None):
|
|
504
|
+
raise NotImplementedError("This is an abstract class.")
|
|
505
|
+
|
|
506
|
+
def bk_ifftn(self, data,dim=None,norm=None):
|
|
507
|
+
raise NotImplementedError("This is an abstract class.")
|
|
508
|
+
|
|
509
|
+
def bk_rfft(self, data):
|
|
510
|
+
raise NotImplementedError("This is an abstract class.")
|
|
511
|
+
|
|
512
|
+
def bk_irfft(self, data):
|
|
513
|
+
raise NotImplementedError("This is an abstract class.")
|
|
514
|
+
|
|
515
|
+
def bk_conjugate(self, data):
|
|
516
|
+
raise NotImplementedError("This is an abstract class.")
|
|
517
|
+
|
|
518
|
+
def bk_real(self, data):
|
|
519
|
+
raise NotImplementedError("This is an abstract class.")
|
|
520
|
+
|
|
521
|
+
def bk_imag(self, data):
|
|
522
|
+
raise NotImplementedError("This is an abstract class.")
|
|
523
|
+
|
|
524
|
+
def bk_relu(self, x):
|
|
525
|
+
raise NotImplementedError("This is an abstract class.")
|
|
526
|
+
|
|
527
|
+
def bk_clip_by_value(self, x,xmin,xmax):
|
|
528
|
+
raise NotImplementedError("This is an abstract class.")
|
|
529
|
+
|
|
530
|
+
def bk_cast(self, x):
|
|
531
|
+
raise NotImplementedError("This is an abstract class.")
|
|
532
|
+
|
|
533
|
+
def bk_variable(self,x):
|
|
534
|
+
raise NotImplementedError("This is an abstract class.")
|
|
535
|
+
|
|
536
|
+
def bk_assign(self,x,y):
|
|
537
|
+
raise NotImplementedError("This is an abstract class.")
|
|
538
|
+
|
|
539
|
+
def bk_constant(self,x):
|
|
540
|
+
raise NotImplementedError("This is an abstract class.")
|
|
541
|
+
|
|
542
|
+
def bk_empty(self,x):
|
|
543
|
+
raise NotImplementedError("This is an abstract class.")
|
|
544
|
+
|
|
545
|
+
def to_numpy(self,x):
|
|
546
|
+
raise NotImplementedError("This is an abstract class.")
|