#include <vector>
#include <cmath>
#include <random>
#include<iostream>
// Sigmoid激活函数
double sigmoid(double x) {
return 1.0 / (1.0 + exp(-x));
}
// RNN单元
class RNNCell {
private:
int input_size;
int hidden_size;
std::vector<std::vector<double>> Wxh;
std::vector<std::vector<double>> Whh;
std::vector<double> bh;
std::vector<double> state;
// 初始化权重和偏置
void init_parameters() {
std::default_random_engine generator;
std::normal_distribution<double> distribution(0.0, 0.1);
// 权重初始化
Wxh.resize(hidden_size, std::vector<double>(input_size));
Whh.resize(hidden_size, std::vector<double>(hidden_size));
for (auto &row : Wxh)
for (auto &val : row)
val = distribution(generator);
for (auto &row : Whh)
for (auto