attractivechaos / kann

A lightweight C library for artificial neural networks
Other
678 stars 117 forks source link

A time series data example for LSTM #41

Open webroot opened 3 years ago

webroot commented 3 years ago

I have inputs (dimension 2) and outputs (1) sequence like below all numbers are normalized ( -1 to 1 )

below is copied 2 samples from training data

(-0.70,-0.23) (-0.70,-0.23) (-0.70,-0.23) (-0.70,-0.23) (-0.70,-0.23) 0.03 (-0.61,-0.26) (-0.61,-0.26) (-0.61,-0.26) (-0.61,-0.26) (-0.61,-0.26) -0.20

here last column is a output vector of size 1 and before that we have 5 unrolling pairs of data points, Can you pls point me how to write training routine for above example. I didn't understand much from your rnn-bit example is quite different use case and textgen is difficult to understand.

I tried like below, but i dont think its KANN_F_TRUTH array is correctly populated

for (int j = 0; j < num_rows - batch_size_; j += batch_size_) {

            int k;
            for (k = 0; k < ulen; ++k) {
                for (int b = 0; b < batch_size_; ++b) {
                    int s = j + b;/// shuf[j + b];
                    for (int i = 0; i < input_; ++i)
                        x[k][b*input_ + i] = data.x[s][k][i];

                    for (int i = 0; i < output_; ++i)
                        y[k][b*output_ + i] = data.y[s][i]; // <--------------------------- some fix required here
                }
            }

            cost += kann_cost(ua, 0, 1) * ulen * batch_size_;
            n_cerr += kann_class_error(ua, &k);
            tot_base += k;
            //kad_check_grad(ua->n, ua->v, ua->n-1);
            kann_RMSprop(n_var, error, NULL, 0.9f, ua->g, ua->x, r);
            tot += ulen * batch_size_;

        }
tomasmalcata commented 3 years ago

Did you find any answer for this problem?