终于成功的模拟了一个脉冲神经网络的更新过程了,呜呜呜,真不容易啊,改代码改了好久,断断续续的查论文,看SNN的机制。现在终于可以说自己完成了(自豪),开心。
具体代码我不粘贴,因为写的有点多,一下全粘贴出来,可能不太好。主要贴出来新加的内容吧:
首先是时间类
#ifndef TIME_H
#define TIME_H
class Time
{
public:
Time();
~Time();
/// <summary>
/// 根据时间步返回当前的时间
/// </summary>
/// <param name="step_">时间步</param>
/// <returns>当前时间</returns>
double get_ms(int step_);
/// <summary>
/// 返回当前的时间步的个数
/// </summary>
/// <returns></returns>
int get_step();
/// <summary>
/// 在每个时间片结束,需要更新运行的时间步
/// </summary>
/// <param name="min_delay">最小延迟</param>
void update(int min_delay);
private:
double dt; //仿真精度
int step; // 运行的时间步的个数
};
Time::Time():dt(0.1),step(0)
{
}
Time::~Time()
{
}
double Time::get_ms(int step_)
{
return step_ * dt;
}
int Time::get_step()
{
return step;
}
void Time::update(int min_delay)
{
step += min_delay;
}
#endif // !TIME_H
因为在每一个时间片都需要保存已经运行的时间步,而且对全局可用,所以,在Manager.h中加入set和get方法
来看看最终的运行效果
哈哈,开心。
接下来就是代码的优化了。其实最终目的肯定是分布式运行,不过也没必要着急。慢慢来就行,加油!!!