-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error - 'sciann.functionals' has no attribute 'mlp_functional' #79
Comments
HI @ssingh-ipa, import sciann as sn
act = "tanh"
x = sn.Variable('x')
tao = sn.Variable('tao')
C_n = sn.Functional('C_n', [x,tao], [10,20,40,20,10], act)
PDE = (sn.diff(C_n, tao)) - ((2*sn.diff(C_n,x) + x*sn.diff(C_n, x, order=2))) |
Hi @linuswalter, I ran this code snippet in JupyterNotebook and it works without errors. However, I switched to the new version of sciann and ran the same code snippet in Spyder. That's when I started getting this mlp_functional error. I have now switched to the old version, and the code works now. I am now running into another issue related to the size of my dataset. Please help me with this one. Here is my code snippet:
I get the following memory error: It is not clear in the documentation how to assign the inputs for training the model. Also, my input files are large files of experimental data. Please suggest how to solve this issue. |
@ssingh-ipa, I think you should prepare your target data differently. |
@linuswalter Thank you. x_input_n is a normalized value, so yes, I can try to sample it randomly as done in Mandel's problem. However, norm_Jn is a function of a parameter (Current), which is a time series input. Hence the physical meaning of BC2 is that at x=1 and tao>0, This is a Neumann boundary condition, and I couldn't find similar examples for reference. What would you suggest for this? |
@ssingh-ipa ah, I think I understand your problem better now. Well if import sciann as sn
act = "tanh
x = sn.Variable('x', dtype=dtype)
tao = sn.Variable('tao', dtype=dtype)
norm_Jn = sn.Functional('norm_Jn', [tao], 4*[10], "tanh")
C_n = sn.Functional('C_n', [x,tao], [10,20,40,20,10], act)
PDE_neg = (x*diff(C_n, tao)) - ((2*diff(C_n,x) + x*diff(C_n, x, order=2)))
IC = (tao==0)*(0.<=x<=1.)*(C_n-1)
BC1 = (x==0)*(tao>0)*diff(C_n,x)
BC2 = (x==1)*(tao>0)*(diff(C_n,x)-norm_Jn) #norm_Jn is an array of size (26362,)
targets_norm_Jn = norm_Jn
mod_norm_Jn = sn.SciModel([tao],[targets_norm_Jn], optimizer="adam",loss_func="mse")
model_n = sn.SciModel([x, tao], [PDE_neg,IC,BC1,BC2], loss_func="mse", optimizer="adam")
tao_value_neg = Dsneg*Time/(Rneg**2) #tao_value_neg is also an array of size (26362,)
normalized_tao_neg = NormalizeData(tao_value_neg).to_numpy()
tao_input_neg = normalized_tao_neg.flatten()
x_input_n = np.linspace(0, 1, 200)
x_input_n_mesh, tao_input_n_mesh = np.meshgrid(
x_input_n,
tao_input_neg
)
x_in_n = np.reshape(x_input_n_mesh, (-1))
tao_in_n = np.reshape(tao_input_n_mesh, (-1))
norm_Jn.set_trainable(True)
mod_norm_Jn.compile()
H_norm_Jn = mod_norm_Jn.train([tao_in_n], target_values_norm_Jn)
norm_Jn.set_trainable(False)
mod_norm_Jn.compile()
H_C_n = model_n.train(...) Well, the values for target_values_norm_Jn = [(Array_of_indices,Array_of_target_values)] The shape of The following example is from the data generator in 1D with 4 different targets. Please note, that each column of the In your case, you have to assign values different than Best, Linus |
Hi Linus @linuswalter, This definitely helps. Thanks a lot. I have 2 open points:
The meshgrid issue will be solved once I integrate the Datagenerator in my code. For reference, are there any examples where XT data generator is implemented? Best, |
Hi Soumya,
Actually, an alternative to representing BC2 = (x==1)*(tao>0)*(diff(C_n,x)-norm_Jn) Instead, you could define BC2 = (x==1)*(tao>0)*(diff(C_n,x)) and assign the array Actually, the application Example of Terzaghi uses the DataGeneratorXT: https://github.com/sciann/sciann-applications/tree/master/SciANN-PoroElasticity I hope this helps you a bit. Best, |
I am getting the following error when I execute a PDE using sciann.
x = sn.Variable('x', dtype=dtype)
tao = sn.Variable('tao', dtype=dtype)
C_n = sn.Functional('C_n', [x,tao], [10,20,40,20,10], act)
PDE = (xdiff(C_n, tao)) - ((2diff(C_n,x) + x*diff(C_n, x, order=2)))
Input In [63] in <cell line: 9>
PDE = (xdiff(C_n, tao)) - ((2diff(C_n,x) + x*diff(C_n, x, order=2)))
File ~\Anaconda3\lib\site-packages\sciann\utils\math.py:1358 in grad
return _gdiff("Grad", f, *args, **kwargs)
File ~\Anaconda3\lib\site-packages\sciann\utils\math.py:1277 in _gdiff
assert is_functional(f), \
File ~\Anaconda3\lib\site-packages\sciann\utils\validations.py:25 in is_functional
if isinstance(f, (sciann.functionals.mlp_functional.MLPFunctional,
AttributeError: module 'sciann.functionals' has no attribute 'mlp_functional'
Please suggest how to solve this.
The text was updated successfully, but these errors were encountered: