DeepGPR 0.0.11__tar.gz → 0.0.12__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.
- {deepgpr-0.0.11 → deepgpr-0.0.12}/PKG-INFO +1 -1
- {deepgpr-0.0.11 → deepgpr-0.0.12}/pyproject.toml +1 -1
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/common.py +2 -18
- deepgpr-0.0.12/src/DeepGPR/lib/deepgpr.so +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/multiscale.py +1 -1
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR.egg-info/PKG-INFO +1 -1
- deepgpr-0.0.11/src/DeepGPR/lib/deepgpr.so +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/README.md +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/setup.cfg +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/__init__.py +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/compute2.py +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/lib/deepgpr.cu +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/lib/deepgpr.dll +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR/wavelet.py +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR.egg-info/SOURCES.txt +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR.egg-info/dependency_links.txt +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR.egg-info/requires.txt +0 -0
- {deepgpr-0.0.11 → deepgpr-0.0.12}/src/DeepGPR.egg-info/top_level.txt +0 -0
|
@@ -149,29 +149,18 @@ class TVRegularization(nn.Module):
|
|
|
149
149
|
self.method = method
|
|
150
150
|
|
|
151
151
|
def _compute_tv(self, data):
|
|
152
|
-
"""
|
|
153
|
-
自动适应 2D [H, W] 或 3D [D, H, W] / [H, W, C] 的 TV 计算
|
|
154
|
-
"""
|
|
155
|
-
# 1. 维度清洗:如果是 [H, W, 1],先去掉那个 1
|
|
156
152
|
if data.dim() == 3 and data.shape[-1] == 1:
|
|
157
153
|
data = data.squeeze(-1)
|
|
158
154
|
|
|
159
|
-
# 2. 根据维度分情况计算梯度
|
|
160
155
|
if data.dim() == 2:
|
|
161
|
-
# --- 2D 情况 [H, W] ---
|
|
162
|
-
# X方向差分 (行与行之间)
|
|
163
156
|
d_x = data[1:, :] - data[:-1, :]
|
|
164
|
-
# Y方向差分 (列与列之间)
|
|
165
157
|
d_y = data[:, 1:] - data[:, :-1]
|
|
166
158
|
|
|
167
|
-
# 2D 肯定没有 Z 方向
|
|
168
159
|
loss_x = torch.sum(torch.abs(d_x))
|
|
169
160
|
loss_y = torch.sum(torch.abs(d_y))
|
|
170
161
|
loss_z = 0.0
|
|
171
162
|
|
|
172
163
|
elif data.dim() == 3:
|
|
173
|
-
# --- 3D 情况 [D, H, W] ---
|
|
174
|
-
# 假设第0维是深度/X,第1维是高度/Y,第2维是宽度/Z
|
|
175
164
|
d_x = data[1:, :, :] - data[:-1, :, :]
|
|
176
165
|
d_y = data[:, 1:, :] - data[:, :-1, :]
|
|
177
166
|
d_z = data[:, :, 1:] - data[:, :, :-1]
|
|
@@ -181,8 +170,6 @@ class TVRegularization(nn.Module):
|
|
|
181
170
|
loss_z = torch.sum(torch.abs(d_z))
|
|
182
171
|
|
|
183
172
|
elif data.dim() == 4:
|
|
184
|
-
# --- 4D 情况 [Batch, Channel, H, W] ---
|
|
185
|
-
# 常见于图像处理习惯
|
|
186
173
|
d_x = data[..., 1:, :] - data[..., :-1, :]
|
|
187
174
|
d_y = data[..., :, 1:] - data[..., :, :-1]
|
|
188
175
|
|
|
@@ -191,16 +178,13 @@ class TVRegularization(nn.Module):
|
|
|
191
178
|
loss_z = 0.0
|
|
192
179
|
|
|
193
180
|
else:
|
|
194
|
-
# 避免标量或1D数据报错
|
|
195
181
|
return torch.tensor(0.0, device=data.device)
|
|
196
182
|
|
|
197
|
-
# 3. 汇总 Loss
|
|
198
183
|
if self.method == 'anisotropic':
|
|
199
|
-
|
|
184
|
+
|
|
200
185
|
total_tv = loss_x + loss_y + loss_z
|
|
201
186
|
else:
|
|
202
|
-
|
|
203
|
-
# 注意:严谨的各向同性需要对每个像素点求平方和再sum,这里简化处理以保持计算图简单
|
|
187
|
+
|
|
204
188
|
total_tv = (loss_x**2 + loss_y**2 + loss_z**2 + 1e-8).sqrt()
|
|
205
189
|
|
|
206
190
|
return total_tv
|
|
Binary file
|
|
@@ -38,7 +38,7 @@ def apply_filter(data: torch.Tensor, fs: float, cutoff: float) -> torch.Tensor:
|
|
|
38
38
|
return filtered.view(step, nrx, iterations).permute(0, 2, 1)
|
|
39
39
|
|
|
40
40
|
else:
|
|
41
|
-
raise ValueError(f"
|
|
41
|
+
raise ValueError(f"Data dimension: {data.ndim}。expected 1D or 3D tensor。")
|
|
42
42
|
|
|
43
43
|
def hilbert_transform(data_in, p=1):
|
|
44
44
|
ns, nt, nr = data_in.shape
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|