model.add(Dense(neurons, activation="relu")) model.add(Dense(neurons, activation="relu")) model.add(Dense(1, activation="sigmoid")) model.compile(optimizer="rmsprop", loss="mse", metrics=["mae"]) model.fit(datalist, scalars, epochs=50, batch_size=64) predicted_scalars = model.predict(datalist) model.summary() idx = 0 vispred = np.zeros([n, n, n]) for i, x in enumerate(ls): for j, y in enumerate(ls): for k, z in enumerate(ls): vispred[i, j, k] = predicted_scalars[idx] idx += 1 v1 = Volume(visdata) v2 = Volume(vispred) s1 = v1.isosurface(threshold=[t for t in arange(0, 1, 0.1)]) s1.alpha(0.5) s2 = v2.isosurface(threshold=[t for t in arange(0, 1, 0.1)]) s2.alpha(0.5) show([[v1, s1], s2], N=2, axes=8)
model = Sequential() model.add(Dense(neurons, activation="relu", input_dim=3)) model.add(Dense(neurons, activation="relu")) model.add(Dense(neurons, activation="relu")) model.add(Dense(1, activation="sigmoid")) model.compile(optimizer="rmsprop", loss="mse", metrics=["mae"]) model.fit(shuffled_datalist, shuffled_scalars, epochs=epochs, batch_size=max(nx, ny, nz)) predicted_scalars = model.predict(datalist) model.summary() idx = 0 vispred = np.zeros([nx, ny, nz]) for i, x in enumerate(lsx): for j, y in enumerate(lsy): for k, z in enumerate(lsz): vispred[i, j, k] = predicted_scalars[idx] idx += 1 v1 = Volume(visdata) v2 = Volume(vispred) s1 = v1.isosurface(threshold=0).alpha(0.8) s2 = v2.isosurface(threshold=0).alpha(0.8) show(v1, v2, s1, s2, N=4, axes=8, bg="w")
print('Test getMeshes') assert len(asse.unpack()) == 2 assert asse.unpack(0) == cone assert asse.unpack(1) == sphere assert 4.1 < asse.diagonalSize() < 4.2 ############################################################################ Volume X, Y, Z = np.mgrid[:30, :30, :30] scalar_field = ((X - 15)**2 + (Y - 15)**2 + (Z - 15)**2) / 225 print('Test Volume, scalar min, max =', np.min(scalar_field), np.max(scalar_field)) vol = Volume(scalar_field) volarr = vol.getPointArray() assert volarr.shape[0] == 27000 assert np.max(volarr) == 3 assert np.min(volarr) == 0 ###################################### isosurface print('Test isosurface') iso = vol.isosurface(threshold=1.0) print('area', iso.area()) assert 2540 < iso.area() < 3000 #lego = vol.legosurface(vmin=0.3, vmax=0.5) #show(lego) #print('lego.N()', lego.N()) #assert 2610 < lego.N() < 2630