本文整理汇总了C++中NeuralNetwork::get_independent_parameters_pointer方法的典型用法代码示例。如果您正苦于以下问题:C++ NeuralNetwork::get_independent_parameters_pointer方法的具体用法?C++ NeuralNetwork::get_independent_parameters_pointer怎么用?C++ NeuralNetwork::get_independent_parameters_pointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NeuralNetwork
的用法示例。
在下文中一共展示了NeuralNetwork::get_independent_parameters_pointer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_save
void NeuralNetworkTest::test_save(void) {
message += "test_save\n";
std::string file_name = "../data/neural_network.xml";
NeuralNetwork nn;
IndependentParameters* ipp;
// Empty multilayer perceptron
nn.set();
nn.save(file_name);
// Only network architecture
nn.set(2, 4, 3);
nn.save(file_name);
// Only independent parameters
nn.set(2);
nn.save(file_name);
// Both network architecture and independent parameters
nn.set(1, 1, 1);
nn.construct_independent_parameters();
ipp = nn.get_independent_parameters_pointer();
ipp->set_parameters_number(1);
nn.save(file_name);
}
示例2: car_copy
Vector<double> Car::calculate_final_solutions(const NeuralNetwork& neural_network) const
{
Car car_copy(*this);
car_copy.set_final_independent_variable(neural_network.get_independent_parameters_pointer()->get_parameter(0));
switch(solution_method)
{
case RungeKutta:
{
return(car_copy.calculate_Runge_Kutta_final_solution(neural_network));
}
break;
case RungeKuttaFehlberg:
{
return(car_copy.calculate_Runge_Kutta_Fehlberg_final_solution(neural_network));
}
break;
default:
{
std::ostringstream buffer;
buffer << "OpenNN Exception: Car class\n"
<< "Vector<double> calculate_final_solutions(const NeuralNetwork&) const method.\n"
<< "Unknown solution method.\n";
throw std::logic_error(buffer.str());
}
break;
}
}
示例3: test_get_independent_parameters_pointer
void NeuralNetworkTest::test_get_independent_parameters_pointer(void) {
message += "test_get_independent_parameters_pointer\n";
NeuralNetwork nn;
nn.construct_independent_parameters();
// Test
assert_true(nn.get_independent_parameters_pointer() != NULL, LOG);
}
示例4: test_initialize_parameters
void NeuralNetworkTest::test_initialize_parameters(void) {
message += "test_initialize_parameters\n";
NeuralNetwork nn;
Vector<double> parameters;
IndependentParameters* ip;
// Test
nn.set(1, 1, 1);
nn.construct_independent_parameters();
ip = nn.get_independent_parameters_pointer();
ip->set_parameters_number(1);
nn.randomize_parameters_normal(1.0, 0.0);
parameters = nn.arrange_parameters();
assert_true(parameters == 1.0, LOG);
}
示例5: solutions
Matrix<double> Cylinder::calculate_solutions(const NeuralNetwork& neural_network) const
{
IndependentParameters* independent_parameters_pointer = neural_network.get_independent_parameters_pointer();
const Vector<double> argument = independent_parameters_pointer->get_parameters();
double x = argument[0];
double y = argument[1];
Matrix<double> solutions(1, 1);
if(pow(x,2) + pow(y,2) <= 1.0)
{
solutions[0][0] = 0.0;
}
else
{
solutions[0][0] = pow(x,2) + pow(y,2) - 1.0;
}
return(solutions);
}
示例6: test_set_parameters
void NeuralNetworkTest::test_set_parameters(void) {
message += "test_set_parameters\n";
Vector<unsigned> multilayer_perceptron_architecture;
NeuralNetwork nn;
unsigned parameters_number;
Vector<double> parameters;
// Test
nn.set_parameters(parameters);
parameters = nn.arrange_parameters();
assert_true(parameters.size() == 0, LOG);
// Test
multilayer_perceptron_architecture.set(2, 2);
nn.set(multilayer_perceptron_architecture);
nn.construct_independent_parameters();
nn.get_independent_parameters_pointer()->set_parameters_number(2);
parameters_number = nn.count_parameters_number();
parameters.set(0.0, 1.0, parameters_number - 1);
nn.set_parameters(parameters);
parameters = nn.arrange_parameters();
assert_true(parameters.size() == parameters_number, LOG);
assert_true(parameters[0] == 0.0, LOG);
assert_true(parameters[parameters_number - 1] == parameters_number - 1.0,
LOG);
}
示例7: write_input_file_independent_parameters
void PlugIn::write_input_file_independent_parameters(
const NeuralNetwork& neural_network) const {
const IndependentParameters* independent_parameters_pointer =
neural_network.get_independent_parameters_pointer();
#ifndef NDEBUG
if (!independent_parameters_pointer) {
std::ostringstream buffer;
buffer
<< "OpenNN Exception: PlugIn class.\n"
<< "void write_input_file_independent_parameters(void) const method.\n"
<< "Pointer to independent parameters is null.\n";
throw std::logic_error(buffer.str());
}
#endif
const Vector<double> independent_parameters =
independent_parameters_pointer->get_parameters();
// unsigned input_flags_number = input_flags.size();
// unsigned independent_parameters_number = independent_parameters.size();
//// Control sentence
// if(input_flags_number != independent_parameters_number)
//{
// buffer << "OpenNN Exception: PlugIn class.\n"
// << "void write_input_file_independent_parameters(void) const
// method.\n"
// << "Number of inputs flags must be equal to number of independent
// parameters.\n";
// throw std::logic_error(buffer.str());
//}
//// Template file
// std::ifstream template_file(template_file_name.c_str());
// if(!template_file.is_open())
//{
// buffer << "OpenNN Exception: PlugIn class.\n"
// << "void write_input_file_independent_parameters(void) const
// method.\n"
// << "Cannot open template file.\n";
//
// throw std::logic_error(buffer.str());
//}
// std::string file_string;
// std::string line;
// while(getline(template_file, line))
//{
// file_string += line;
// file_string += "\n";
//}
// template_file.close();
//// Convert values to string
// Vector<std::string> independent_parameters_string =
// independent_parameters.get_string_vector();
//// Replace flags by values as many times flags are found in string
// for(unsigned i = 0; i < input_flags_number; i++)
//{
// while(file_string.find(input_flags[i]) != std::string::npos)
// {
// size_t found = file_string.find(input_flags[i]);
// if(found != std::string::npos)
// {
// file_string.replace(file_string.find(input_flags[i]),
// input_flags[i].length(), independent_parameters_string[i]);
// }
// }
//}
//// Input file
// std::ofstream input_file(input_file_name.c_str());
//
// if(!input_file.is_open())
//{
// buffer << "OpenNN Exception: PlugIn class.\n"
// << "void write_input_file(void) const method.\n"
// << "Cannot open inputs file.\n";
//
// throw std::logic_error(buffer.str());
//}
// input_file << file_string << "\n";
//.........这里部分代码省略.........