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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DeepGPR
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: PyTorch and CUDA for GPR FWI
5
5
  Author-email: Lei Liu <liulei990222@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
7
7
 
8
8
  [project]
9
9
  name = "DeepGPR"
10
- version = "0.0.11"
10
+ version = "0.0.12"
11
11
  authors = [
12
12
  { name = "Lei Liu", email = "liulei990222@gmail.com" }
13
13
  ]
@@ -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
- # 各向异性:直接相加 (|dx| + |dy|)
184
+
200
185
  total_tv = loss_x + loss_y + loss_z
201
186
  else:
202
- # 各向同性:平方和开根 (sqrt(dx^2 + dy^2)) - 简化版近似
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
@@ -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"不支持的数据维度: {data.ndim}。期望 1D 或 3D tensor。")
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: DeepGPR
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: PyTorch and CUDA for GPR FWI
5
5
  Author-email: Lei Liu <liulei990222@gmail.com>
6
6
  Classifier: Programming Language :: Python :: 3
Binary file
File without changes
File without changes