neuralhydrology / neuralhydrology

Python library to train neural networks with a strong focus on hydrological applications.
https://neuralhydrology.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
330 stars 164 forks source link

General issues #141

Closed Kavindra95 closed 11 months ago

Kavindra95 commented 11 months ago

Recently, I started to learn about nueralhydrology and have little knowledge of python. When I try to run your tutorials, the " test " folder required for evaluation is not created in "test_run" folder. What can be the issue? Thank you.

kratzert commented 11 months ago

Can you be a bit more specific. The "test" subdirectory is not required for evaluation but instead is created in the process of evaluating the model on the test set. Therefore I struggle to understand your problem. Can you maybe specify which tutorial you are trying to run and copy the error message (or make a screenshot)

Kavindra95 commented 11 months ago

I am sorry, I found there was a mistake from my side. Now I can run "Introduction to NeuralHydrology" tutorial. And again I am facing a problem when I try to change training, validating and testing periods. I do not get simulated results after year 2008. I attach two screenshots below. Thank you.

Periods Plot

kratzert commented 11 months ago

Even though I don't know which tutorial you are running, I don't think there is any error at all. I think the reason is quite simple: Whatever model you train, you are most likely using the Maurer forcings and for the Maurer forcings, the inputs stop at the end of 2008. If you don't have inputs, you can't do predictions. You see from the plots and your periods that the model runs over all three periods (because there are predictions in the training, validation and also half of the test period). So just have a look at the forcing file that is used for this model and you will see that the meteorological data stops at the end of 2008.

Kavindra95 commented 10 months ago

Dear Dr. Kratzert,

Thank you for getting back to me. As you mentioned, the problem was the unavailability of forcing input data after 2008. I could get the results successfully after adjusting the 3 periods accordingly. (The tutorial I followed was "Introduction to NeuralHydrology" tutorial which used the "CAMELS_US" data set)

How can I adjust the configuration file to get a sequence of predictions? I changed the "model" to "sequential_forecast_lstm" and added "forecast_seq_length" key to the configuration file and ran the model, but a few errors were encountered. I am not sure that the changes I made were correct. I look forward to hearing from you. Thank you for your time.

Best regards, Kavindra.

On Mon, Aug 21, 2023 at 2:17 AM Frederik Kratzert @.***> wrote:

Even though I don't know which tutorial you are running, I don't think there is any error at all. I think the reason is quite simple: Whatever model you train, you are most likely using the Maurer forcings and for the Maurer forcings, the inputs stop at the end of 2008. If you don't have inputs, you can't do predictions. You see from the plots and your periods that the model runs over all three periods (because there are predictions in the training, validation and also half of the test period). So just have a look at the forcing file that is used for this model and you will see that the meteorological data stops at the end of 2008.

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1685781301, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA3H7WYHQSEXMQNXHGTXWMDPBANCNFSM6AAAAAA3JAUXNY . You are receiving this because you authored the thread.Message ID: @.***>

danklotz commented 10 months ago

How can I adjust the configuration file to get a sequence of predictions?

You are probably seeking for the predict_last_n config argument (see here)

Kavindra95 commented 10 months ago

Thanks, I'll check it out.

On Tue, Sep 19, 2023 at 12:59 AM Daniel Klotz @.***> wrote:

How can I adjust the configuration file to get a sequence of predictions?

You are probably seeking for the predict_last_n config argument (see here https://neuralhydrology.readthedocs.io/en/latest/usage/config.html)

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1724875499, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA2LYL333D6Y4ZDJT4TX3EYFTANCNFSM6AAAAAA3JAUXNY . You are receiving this because you authored the thread.Message ID: @.***>

Kavindra95 commented 9 months ago

Good day,

Hope this email finds you well. I just look for a clue again. Is there any way to change the "last n value" of the sequences at each time step? (as an example if I want to change the last 3 values of input sequences to zero, at each time step)

Thank you, Kavindra.

On Fri, Sep 22, 2023 at 1:27 PM Lewke @.***> wrote:

Thanks, I'll check it out.

On Tue, Sep 19, 2023 at 12:59 AM Daniel Klotz @.***> wrote:

How can I adjust the configuration file to get a sequence of predictions?

You are probably seeking for the predict_last_n config argument (see here https://neuralhydrology.readthedocs.io/en/latest/usage/config.html)

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1724875499, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA2LYL333D6Y4ZDJT4TX3EYFTANCNFSM6AAAAAA3JAUXNY . You are receiving this because you authored the thread.Message ID: @.***>

Kavindra95 commented 9 months ago

Hello,

I just wanted to check if you got any chance to look at my previous email.

Thank you, Kavindra

On Thu, Oct 5, 2023 at 4:59 PM Lewke @.***> wrote:

Good day,

Hope this email finds you well. I just look for a clue again. Is there any way to change the "last n value" of the sequences at each time step? (as an example if I want to change the last 3 values of input sequences to zero, at each time step)

Thank you, Kavindra.

On Fri, Sep 22, 2023 at 1:27 PM Lewke @.***> wrote:

Thanks, I'll check it out.

On Tue, Sep 19, 2023 at 12:59 AM Daniel Klotz @.***> wrote:

How can I adjust the configuration file to get a sequence of predictions?

You are probably seeking for the predict_last_n config argument (see here https://neuralhydrology.readthedocs.io/en/latest/usage/config.html)

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1724875499, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA2LYL333D6Y4ZDJT4TX3EYFTANCNFSM6AAAAAA3JAUXNY . You are receiving this because you authored the thread.Message ID: @.***>

gauchm commented 9 months ago

I don't think we support this out of the box. But you can easily adapt the __getitem__ method in basedataset.py to set the last n values of the features in x_d (or x_h/x_f for forecasting models) to zero, which should do exactly what (I think) you describe.

Kavindra95 commented 9 months ago

Thank you for the hint. Before replacing last n values by whatever value, do I have to normalize it?

Kavindra.

On Tue, Oct 17, 2023 at 12:26 AM Martin Gauch @.***> wrote:

I don't think we support this out of the box. But you can easily adapt the getitem method in basedataset.py to set the last n values of the features in x_d (or x_h/x_f for forecasting models) to zero, which should do exactly what (I think) you describe.

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1765692441, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA4WS3V7GUASUFSJ6YTX7YJJ5AVCNFSM6AAAAAA3JAUXN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONRVGY4TENBUGE . You are receiving this because you authored the thread.Message ID: @.***>

gauchm commented 9 months ago

Whatever you do in getitem is happening after normalization, so if you set some value to x there, it will arrive as x in the model. So if you use 0 like in your example, the model would think that the last n time steps of that variable are as high as the variable's mean (if you use zero-mean/unit variance normalization).

Kavindra95 commented 8 months ago

Ok, thanks for the clarification.

On Sun, Oct 22, 2023 at 8:30 AM Martin Gauch @.***> wrote:

Whatever you do in getitem is happening after normalization, so if you set some value to x there, it will arrive as x in the model. So if you use 0 like in your example, the model would think that the last n time steps of that variable are as high as the variable's mean (if you use zero-mean/unit variance normalization).

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1774096592, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA7Z3L2IGDD45YCUWI3YAUNXDAVCNFSM6AAAAAA3JAUXN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGA4TMNJZGI . You are receiving this because you authored the thread.Message ID: @.***>

Kavindra95 commented 8 months ago

Hi Mr. Martin,

Your previous information helped a lot. Now I just want to clarify how "lagged_features" works. I just have 2 basic questions mentioned below.

  1. if I add one of the "dynamic_inputs" input variables as a "lagged_features", does the model ignore the original/raw feature of the lagged feature as an input?
  2. if I use 1 number of lagged time steps, does the model consider the previous time step value of the original data as the current time step value of the lagged data?

I attached a screenshot of my configuration file showing how I added the "lagged_features". I am just wondering it is the right way or not.

Thank you, Kavindra.

On Sat, Oct 28, 2023 at 12:30 PM Lewke @.***> wrote:

Ok, thanks for the clarification.

On Sun, Oct 22, 2023 at 8:30 AM Martin Gauch @.***> wrote:

Whatever you do in getitem is happening after normalization, so if you set some value to x there, it will arrive as x in the model. So if you use 0 like in your example, the model would think that the last n time steps of that variable are as high as the variable's mean (if you use zero-mean/unit variance normalization).

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1774096592, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA7Z3L2IGDD45YCUWI3YAUNXDAVCNFSM6AAAAAA3JAUXN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZUGA4TMNJZGI . You are receiving this because you authored the thread.Message ID: @.***>

gauchm commented 8 months ago

Re 1: The model will use all the variables you specify in dynamic_inputs. If you specify the original feature there, it will be used. If you only specify the lagged feature, it won't. Re 2: I think the answer to your question is yes, but I'm not sure I understand the question. We use pandas shift, so the effect is the same as it is there.

Maybe you just fire up a juypter notebook or a colab and inspect the data returned by your dataset given your config? Maybe do some plots of the different timeseries that the dataset returns? You can find an example for loading a dataset in this tutorial (especially cell 7). This way, you'll get a better understanding of the effects of your config settings.

Kavindra95 commented 7 months ago

Ok, thanks for the clarification.

On Fri, Nov 3, 2023 at 4:00 AM Martin Gauch @.***> wrote:

Re 1: The model will use all the variables you specify in dynamic_inputs. If you specify the original feature there, it will be used. If you only specify the lagged feature, it won't. Re 2: I think the answer to your question is yes, but I'm not sure I understand the question. We use pandas shift https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.shift.html#pandas-dataframe-shift, so the effect is the same as it is there.

Maybe you just fire up a juypter notebook or a colab and inspect the data returned by your dataset given your config? Maybe do some plots of the different timeseries that the dataset returns? You can find an example for loading a dataset in this tutorial https://neuralhydrology.readthedocs.io/en/latest/tutorials/inspect-lstm.html (especially cell 7). This way, you'll get a better understanding of the effects of your config settings.

— Reply to this email directly, view it on GitHub https://github.com/neuralhydrology/neuralhydrology/issues/141#issuecomment-1792075820, or unsubscribe https://github.com/notifications/unsubscribe-auth/A7X4YA6AANQ6YAH2YV5EAZTYCSXBTAVCNFSM6AAAAAA3JAUXN2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJSGA3TKOBSGA . You are receiving this because you authored the thread.Message ID: @.***>