Vector<double> BoundingLayer::calculate_second_derivative(const Vector<double>& inputs) const { std::ostringstream buffer; const size_t bounding_neurons_number = get_bounding_neurons_number(); const Vector<double> outputs = calculate_outputs(inputs); for(size_t i = 0; i < bounding_neurons_number; i++) { if(outputs[i] == lower_bounds[i]) { buffer << "OpenNN Exception: BoundingLayer class.\n" << "Vector<double> calculate_outputs(const Vector<double>&) const method.\n" << "Output is equal to lower bound. The bounding function is not differentiable at this point.\n"; throw std::logic_error(buffer.str()); } else if(outputs[i] == upper_bounds[i]) { buffer << "OpenNN Exception: BoundingLayer class.\n" << "Vector<double> calculate_outputs(const Vector<double>&) const method.\n" << "Output is equal to upper bound. The bounding function is not differentiable at this point.\n"; throw std::logic_error(buffer.str()); } } Vector<double> second_derivative(bounding_neurons_number, 0.0); return(second_derivative); }
void Petri_Conveyor::execute(void* arg) { struct _pulse pulse; init_places(); while (!isStopped()) { if (-1 == MsgReceivePulse(conveyor_dispatcher_Chid, &pulse, sizeof(pulse), NULL)) { if (isStopped()) { break; // channel destroyed, Thread ending } perror("Petri_Motor: MsgReceivePulse"); exit(EXIT_FAILURE); } conveyor_tmpArr = conveyor_dispatcher->get_conveyor_inputs(); set_conveyor_inputs(); process_transitions(); calculate_outputs(); NotifyReactor(); //conveyor_dispatcher->set_disp_Outputs(conveyor_lokal_outputs); } }
Vector<double> BoundingLayer::calculate_derivative(const Vector<double>& inputs) const { const size_t bounding_neurons_number = get_bounding_neurons_number(); const Vector<double> outputs = calculate_outputs(inputs); Vector<double> derivatives(bounding_neurons_number); for(size_t i = 0; i < bounding_neurons_number; i++) { if(outputs[i] <= lower_bounds[i] || outputs[i] >= upper_bounds[i]) { derivatives[i] = 0.0; } else { derivatives[i] = 1.0; } } return(derivatives); }