- added char2vec and vec2char
- refactored git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@859 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+4
-6
@@ -60,10 +60,8 @@ class RbmListener : public Rbm::IListener
|
||||
|
||||
for (int i=0; i < start.size(); i++)
|
||||
{
|
||||
arma::mat curr = zeros(1, RnnTextHelper::NUM_CODES);
|
||||
int idx = RnnTextHelper::ch2idx(start.at(i));
|
||||
curr[idx] = 1;
|
||||
curr_str.append(1,RnnTextHelper::idx2ch(curr.index_max()));
|
||||
curr = Matutils::char2vec(start.at(i), RnnTextHelper::NUM_CODES);
|
||||
curr_str.append(1, Matutils::vec2char(curr));
|
||||
arma::mat r = stack->step_forward(state, curr);
|
||||
next = stack->to_next(r);
|
||||
stack->clamp_one_hot(next);
|
||||
@@ -73,7 +71,7 @@ class RbmListener : public Rbm::IListener
|
||||
for (int i=stack->getSeqLen(); i < t_vc.n_rows; i++)
|
||||
{
|
||||
curr = next;
|
||||
curr_str.append(1,RnnTextHelper::idx2ch(curr.index_max()));
|
||||
curr_str.append(1, Matutils::vec2char(curr));
|
||||
arma::mat r = stack->step_forward(state, curr);
|
||||
next = stack->to_next(r);
|
||||
stack->clamp_one_hot(next);
|
||||
@@ -150,7 +148,7 @@ int main(int argc, char *argv[])
|
||||
for (int i=0; i < t_vc.n_rows; i++)
|
||||
{
|
||||
arma::mat curr = stack->to_curr(t_vc.row(i));
|
||||
char c = RnnTextHelper::idx2ch(curr.index_max());
|
||||
char c = Matutils::vec2char(curr);
|
||||
putchar(c);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
Reference in New Issue
Block a user