π¨βπ»
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
size_t hidden_size = 30; | |
size_t seq_len = 3; //The length of traning srquence | |
network<sequential> nn; | |
nn << recurrent(lstm(3, hidden_size), seq_len); | |
nn << leaky_relu() << fc(hidden_size) << softmax(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xt::xarray<float> compute(xt::xarray<float> input) | |
{ | |
assert(input.size() == 3); | |
//save data for traning | |
if(last_input_.size() != 0) { | |
for(auto v : last_input_) | |
input_.push_back(v); | |
for(auto v : input) | |
output_.push_back(v); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TemporalMemory tm(3*ENCODE_WIDTH, TP_DEPTH); | |
tm->setMaxNewSynapseCount(64); | |
tm->setPermanenceIncrement(0.1); | |
tm->setPermanenceDecrement(0.045); | |
tm->setConnectedPermanence(0.4); | |
tm->setPredictedSegmentDecrement(0.3*2.0f*tm_->getPermanenceIncrement()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
xt::xarray<float> compute(int last_oppo_move, bool learn = true) | |
{ | |
auto out = tm.compute(encode(last_oppo_move), true); //true means enable learning | |
return categroize(3, ENCODE_WIDTH, out); //Convert from SDR to properablity distribution | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main() | |
{ | |
//Initialize both AI | |
RNNPlayer player1; | |
HTMPlayer player2; | |
int rnn_last_move = 0; | |
int htm_last_move = 0; | |
size_t rnn_win = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//build: c++ tmperf.cpp -o tmperf -O3 -lnupic_core | |
//usage: ./tmperf | |
#include <nupic/algorithms/TemporalMemory.hpp> | |
#include <chrono> | |
#include <vector> | |
#include <random> | |
using TemporalMemory = nupic::algorithms::temporal_memory::TemporalMemory; //Yeah.... This is too redundent |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "HTMHelper.hpp" | |
using namespace HTM; | |
int main() | |
{ | |
TemporalMemory tm({16}, 8); | |
CategoryEncoder encoder(2, 8); | |
std::vector<size_t> seq = {0,0,1,1}; |