void neuron::backpropagate() { if(backpropagating_) return; bool fired_recently = std::abs(current_time_ - last_fired_) < 0.003; bool up = false; bool down = false; if(has_class("expected_fire") && !fired_recently) { std::cout << get_label() << " should have fired, didn't " << current_time_ << " " << last_fired_ << " " << (current_time_ - last_fired_) << std::endl; up = true; } else if(has_class("expected_no_fire") && fired_recently) { std::cout << get_label() << " shouldn't have fired, did " << current_time_ << " " << last_fired_ << " " << (current_time_ - last_fired_) << std::endl; down = true; } if(!up && !down) { std::cout << get_label() << " no change" << current_time_ << " " << last_fired_ << " " << (current_time_ - last_fired_) << std::endl; return; } backpropagating_ = true; backpropagation_time_ = current_time_; for(auto connection : inputs_) { if(connection->get_presynaptic()->has_class("collector")) continue; if(current_time_ - connection->get_presynaptic()->last_fired_ < 0.005) { if(up) { connection->get_synapse().backpropagate_up(); connection->send_signal(1); } else { connection->get_synapse().backpropagate_down(); connection->send_signal(2); } } } }
void neuron::on_action_potential_begin() { firing_ = true; last_fired_ = current_time_; for(auto connection : outputs_) { connection->send_signal(0); } if(has_class("expected_fire") || has_class("expected_no_fire")) { std::cout << get_label() << " " << has_class("expected_fire") << " " << has_class("expected_no_fire") << std::endl; for(auto in_connection : inputs_) { for(auto sibling_connection : in_connection->get_presynaptic()->outputs_) { sibling_connection->get_postsynaptic()->backpropagate(); } } } }
void Component::add_class(const std::string& c) { if(css_class.empty()) css_class = " " + c + " "; else if(!has_class(c)) css_class += c + " "; if(style) style->update(css_class); }