foscat 2025.7.2__py3-none-any.whl → 2025.8.3__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/BkTorch.py +34 -3
- foscat/CNN.py +1 -0
- foscat/FoCUS.py +387 -165
- foscat/HOrientedConvol.py +546 -0
- foscat/HealSpline.py +8 -5
- foscat/Synthesis.py +27 -18
- foscat/UNET.py +200 -0
- foscat/scat_cov.py +289 -178
- foscat/scat_cov_map2D.py +1 -1
- {foscat-2025.7.2.dist-info → foscat-2025.8.3.dist-info}/METADATA +1 -1
- {foscat-2025.7.2.dist-info → foscat-2025.8.3.dist-info}/RECORD +14 -12
- {foscat-2025.7.2.dist-info → foscat-2025.8.3.dist-info}/WHEEL +0 -0
- {foscat-2025.7.2.dist-info → foscat-2025.8.3.dist-info}/licenses/LICENSE +0 -0
- {foscat-2025.7.2.dist-info → foscat-2025.8.3.dist-info}/top_level.txt +0 -0
foscat/BkTorch.py
CHANGED
|
@@ -196,10 +196,41 @@ class BkTorch(BackendBase.BackendBase):
|
|
|
196
196
|
y = y.reshape(*leading_dims, O_c, Nx, Ny)
|
|
197
197
|
|
|
198
198
|
return y
|
|
199
|
-
|
|
199
|
+
|
|
200
200
|
def conv1d(self, x, w, strides=[1, 1, 1], padding="SAME"):
|
|
201
|
-
|
|
202
|
-
|
|
201
|
+
"""
|
|
202
|
+
Performs 1D convolution along the last axis of a 2D tensor x[n, m] with kernel w[K].
|
|
203
|
+
|
|
204
|
+
Parameters:
|
|
205
|
+
- x: torch.Tensor of shape [n, m]
|
|
206
|
+
- w: torch.Tensor of shape [K]
|
|
207
|
+
- strides: list of 3 ints; only strides[1] (along axis -1) is used
|
|
208
|
+
- padding: "SAME" or "VALID"
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
- torch.Tensor of shape [n, m] (if SAME) or smaller (if VALID)
|
|
212
|
+
"""
|
|
213
|
+
assert x.ndim == 2, "Input x must be a 2D tensor [n, m]"
|
|
214
|
+
assert w.ndim == 1, "Kernel w must be a 1D tensor [K]"
|
|
215
|
+
stride = strides[1]
|
|
216
|
+
|
|
217
|
+
# Reshape for PyTorch conv1d: [batch, channels, width]
|
|
218
|
+
x_reshaped = x.unsqueeze(1) # [n, 1, m]
|
|
219
|
+
w_flipped = w.flip(0).view(1, 1, -1) # [out_channels=1, in_channels=1, kernel_size]
|
|
220
|
+
|
|
221
|
+
if padding.upper() == "SAME":
|
|
222
|
+
pad_total = w.shape[0] - 1
|
|
223
|
+
pad_left = pad_total // 2
|
|
224
|
+
pad_right = pad_total - pad_left
|
|
225
|
+
x_reshaped = F.pad(x_reshaped, (pad_left, pad_right), mode='constant', value=0)
|
|
226
|
+
padding_mode = 'valid'
|
|
227
|
+
elif padding.upper() == "VALID":
|
|
228
|
+
padding_mode = 'valid'
|
|
229
|
+
else:
|
|
230
|
+
raise ValueError("padding must be either 'SAME' or 'VALID'")
|
|
231
|
+
|
|
232
|
+
out = F.conv1d(x_reshaped, w_flipped, stride=stride, padding=0) # manual padding applied above
|
|
233
|
+
return out.squeeze(1) # [n, m_out]
|
|
203
234
|
|
|
204
235
|
def bk_threshold(self, x, threshold, greater=True):
|
|
205
236
|
|