diff --git a/source/poet.cpp b/source/poet.cpp index 93b5b6e..1e6f5a2 100644 --- a/source/poet.cpp +++ b/source/poet.cpp @@ -40,13 +40,13 @@ class RbmListener : public Rbm::IListener std::cout << "L1 = " << status.L1 << std::endl; std::cout << "L2 = " << status.L2 << std::endl; m_last_progress = status.progress; - forward(); + forward("Chap"); } return true; } - void forward() + void forward(std::string const &start) { RnnStack *stack = reinterpret_cast(&m_stack); arma::mat state; @@ -56,17 +56,17 @@ class RbmListener : public Rbm::IListener std::string next_str; arma::mat t_vc = stack->trainingBatch(); - for (int i=0; i < stack->getSeqLen(); i++) + for (int i=0; i < start.size(); i++) { - curr = stack->to_curr(t_vc.row(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())); arma::mat r = stack->step_forward(state, curr); next = stack->to_next(r); stack->clamp_one_hot(next); - next_str.append(1,RnnTextHelper::idx2ch(next.index_max())); } - cout << "Curr: " << curr_str << std::endl; - cout << "Next: " << next_str << std::endl; + cout << "Start: " << curr_str << std::endl; for (int i=stack->getSeqLen(); i < t_vc.n_rows; i++) { @@ -76,10 +76,8 @@ class RbmListener : public Rbm::IListener next = stack->to_next(r); stack->clamp_one_hot(next); curr = stack->to_curr(r); - next_str.append(1,RnnTextHelper::idx2ch(next.index_max())); } cout << "Curr: " << curr_str << std::endl; - cout << "Next: " << next_str << std::endl; } AStack &m_stack; @@ -154,20 +152,13 @@ int main(int argc, char *argv[]) putchar(c); } printf("\n"); - printf("Next\n"); - for (int i=0; i < t_vc.n_rows; i++) - { - arma::mat next = stack->to_next(t_vc.row(i)); - char c = RnnTextHelper::idx2ch(next.index_max()); - putchar(c); - } - printf("\n"); command = Command::Forward; } if (command == Command::Forward) { - listener.forward(); + char *start = argv[2]; + listener.forward(start); } printf("\nEnd of program\n"); return 0;