Artelnics / opennn

OpenNN - Open Neural Networks Library
http://www.opennn.net
GNU Lesser General Public License v3.0
1.12k stars 353 forks source link

how the Forecasting works? #215

Closed xinsuinizhuan closed 2 years ago

xinsuinizhuan commented 2 years ago

The airline_passengers example, i have two questions: 1、 const Index lags_number = 2; const Index steps_ahead_number = 1; Is it mean the pre tow rows records to forecasting the third record? then what the Calculate outputs mean? it is a 4x3 input ,and get the 4 output, it should not be 2x4 or 2x1? as the: Tensor<type, 2> input_data(1, 2); input_data.setValues({ {112,118} }); I use the 1x2 input data in source data, but the predict result is so bad: 图片 i also use the 4x3 input data in source data, but the predict result also is so bad: 图片 2、how to set the train epochs, i use the : training_strategy.set_maximum_epochs_number(300); but it only train 109

图片

xinsuinizhuan commented 2 years ago

Others, how to convert vector to Tensor<type, 2>, and convert Tensor<type, 2> to vector?

davidge807 commented 2 years ago

Hi again @xinsuinizhuan I'll answer your questions so you understand forecasting:

  1. Lags number = 2 and Steps ahead number = 1 means that we use the last two records to predict the next value. You are correct with the input data dimension; input data should be formed by samples of 1x2 size. In this case, we have four samples ( giving a tensor of 4x2).
  2. Even though you have established 300 as the maximum epochs number, more stopping conditions are checked. In this case, minimum loss decrease is reached.
  3. Can you give us more information about your question? What do you want to achieve?

Thank you very much for all your questions, David.

xinsuinizhuan commented 2 years ago

how about the forecast result? I use the source data in airline_passengers.csv, as the minimum loss decrease, the forecast data shoud be good, but this result is so bad: 图片

Others, how to convert vector to Tensor<type, 2>, and convert Tensor<type, 2> to vector?

davidge807 commented 2 years ago

Hi @xinsuinizhuan

LSTM layer is under development, so its performance won't be as good as desired. We apologize for that.

I can't help you with your vector doubt if you don't give us more information. What do you want to achieve exactly?

xinsuinizhuan commented 2 years ago

About Tensor to vector and vector to Tensor: I read the data from txt and cvs file,and i put them into the vector, but when i want to forecast, i need to convert them to Tensor, as my data is: std::vector mydata = {0.5,0.2,0,11,1.0,2.3}; when i want to predict, Tensor<type, 2> output_data = network->m_pnetwork->calculate_outputs(input_data), the input_data is tensor,so how to convert the vector to tensor. And the output_data is also a tensor,but i need convert it to vector, then to show.

davidge807 commented 2 years ago

You can create an auxiliary DataSet for reading CSV files and obtaining data as a Tensor<type,2> . Following code illustrates how:

DataSet aux_data_set("path.csv", char file_delimiter, false) Tensor<type, 2> mydata = aux_data_set.get_data()

I hope this works for you; thank you very much for your questions, David.