tum-pbs / pbdl-book

Welcome to the Physics-based Deep Learning Book (v0.2)
https://physicsbaseddeeplearning.org/
993 stars 155 forks source link

Question about "1.2 Finding the inverse function of a parabola" #18

Closed ANTAGNIST closed 1 year ago

ANTAGNIST commented 1 year ago

My anaconda list is followed:

I copied the following code in page6: import numpy as np import tensorflow as tf import matplotlib.pyplot as plt # X-Data N = 200 X = np.random.random(N) # Generation Y-Data sign = (- np.ones((N,)))**np.random.randint(2,size=N) Y = np.sqrt(X) * sign # Neural network act = tf.keras.layers.ReLU() nn_sv = tf.keras.models.Sequential([ tf.keras.layers.Dense(10, activation=act), tf.keras.layers.Dense(10, activation=act), tf.keras.layers.Dense(1,activation='linear') ]) # Loss function loss_sv = tf.keras.losses.MeanSquaredError() optimizer_sv = tf.keras.optimizers.Adam(learning_rate=0.001) nn_sv.compile(optimizer=optimizer_sv, loss=loss_sv) # Training results_sv = nn_sv.fit(X, Y, epochs=5, batch_size= 5, verbose=1) But when I runned the code and it runned to Epoch of 1/5: # Training results_sv = nn_sv.fit(X, Y, epochs=5, batch_size= 5, verbose=1) The following quitions occured: Output exceeds the [size limit]. Open the full output data [in a text editor] ValueError Traceback (most recent call last) d:\code\pyMyself\pinn\donw.ipynb Cell 8 in <cell line: 2>() 1 # Training ----> 2 results_sv = nn_sv.fit(X, Y, epochs=5, batch_size= 5, verbose=1)

File d:\Ana\Anaconda3\envs\deepdeS\lib\site-packages\keras\utils\traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs) 67 filtered_tb = _process_traceback_frames(e.traceback) 68 # To get the full stack trace, call: 69 # tf.debugging.disable_traceback_filtering() ---> 70 raise e.with_traceback(filtered_tb) from None 71 finally: 72 del filtered_tb

File ~\AppData\Local\Temp__autograph_generated_filelji_gey6.py:15, in outer_factory..inner_factory..tftrain_function(iterator) 13 try: 14 doreturn = True ---> 15 retval = ag__.converted_call(ag.ld(step_function), (ag.ld(self), ag.ld(iterator)), None, fscope) 16 except: 17 do_return = False

ValueError: in user code:

File "d:\Ana\Anaconda3\envs\deepdeS\lib\site-packages\keras\engine\training.py", line 1160, in train_function  *
    return step_function(self, iterator)

... Call arguments received by layer "sequential_2" " f"(type Sequential): • inputs=tf.Tensor(shape=(5,), dtype=float32) • training=True • mask=None

Could you please tell me what kind of step I did wrong? Thank you very much!

thunil commented 1 year ago

This seems to be a mismatch of the installed version, I can recommend to try it on colab: https://colab.research.google.com/github/tum-pbs/pbdl-book/blob/master/intro-teaser.ipynb

And then you could adapt your local installation accordingly.