Skip to content

Commit f7847a4

Browse files
committed
[WIP] Towards a more stable activation function... hopefully
1 parent 92f3652 commit f7847a4

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tests/test_gradients/test_gradients_I.py

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
data_path = os.path.abspath('../../examples/')
99

1010

11-
def model(sigoid_slope=100):
11+
def model(sigoid_slope=100, plot=False):
1212
geo_model: gp.data.GeoModel = gp.create_geomodel(
1313
project_name='Wells',
1414
extent=[0, 12000, -500, 500, 0, 4000],
15-
resolution=[10, 1, 10],
15+
resolution=np.array([10, 1, 10]) * 1,
1616
refinement=1, # * For this model is better not to use octrees because we want to see what is happening in the scalar fields
1717
importer_helper=gp.data.ImporterHelper(
1818
path_to_orientations=data_path + "/data/2-layers/2-layers_orientations.csv",
@@ -28,23 +28,24 @@ def model(sigoid_slope=100):
2828
backend=gp.data.AvailableBackends.PYTORCH
2929
)
3030
)
31+
32+
if plot:
33+
gpv.plot_2d(geo_model, show_scalar=False, kwargs_lithology={
34+
"plot_grid": True,
35+
"cmap": "viridis"
36+
})
37+
plt.show()
3138
return geo_model
3239

3340

34-
def test_model():
35-
geo_model=model(200)
36-
37-
gpv.plot_2d(geo_model, show_scalar=True, kwargs_lithology={"plot_grid": True})
38-
39-
4041
def test_gradients_numpy():
41-
geo_model = model(1000)
42+
geo_model = model(1000, plot=True)
4243

4344
gpv.plot_2d(geo_model, kwargs_lithology={"plot_grid": True})
4445

4546
par_val = geo_model.surface_points.data['Z'][0]
4647
var = 50
47-
point_n = 1
48+
point_n = 0
4849

4950
values_to_compute = np.linspace(par_val - var, par_val + var, 30)
5051
arrays = np.array([])
@@ -95,6 +96,7 @@ def test_gradients_numpy():
9596
override_regular_grid=gradient_z_sp_1,
9697
kwargs_lithology={
9798
'cmap': 'seismic',
99+
'norm': None,
98100
"plot_grid": True,
99101
"vmin": -max_abs_val,
100102
"vmax": max_abs_val
@@ -104,8 +106,7 @@ def test_gradients_numpy():
104106

105107

106108
def test_gradients_I():
107-
geo_model = model(sigoid_slope=1200)
108-
109+
geo_model = model(sigoid_slope=1200, plot=True)
109110
# * This is the activated block
110111
block = geo_model.solutions.octrees_output[0].last_output_center.final_block
111112

@@ -134,7 +135,7 @@ def test_gradients_I():
134135
print("Gradients:", jacobian)
135136
print("Max min:", jacobian.max(), jacobian.min())
136137

137-
for i in range(1, 2):
138+
for i in range(0, 4):
138139
gradient_z_sp_1 = jacobian[i, 2, :].detach().numpy()
139140

140141
max_abs_val = np.max(np.abs(gradient_z_sp_1))
@@ -146,6 +147,7 @@ def test_gradients_I():
146147
override_regular_grid=gradient_z_sp_1,
147148
kwargs_lithology={
148149
'cmap': 'seismic',
150+
"norm": None,
149151
"plot_grid": True,
150152
"vmin": -max_abs_val,
151153
"vmax": max_abs_val

0 commit comments

Comments
 (0)