Skip to content

Commit

Permalink
merge conflicts fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RoberLopez committed Dec 18, 2024
2 parents 1463abf + b1d2e6d commit d2d7982
Show file tree
Hide file tree
Showing 64 changed files with 1,923 additions and 779 deletions.
1 change: 0 additions & 1 deletion blank/blank.pro
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ else:unix: PRE_TARGETDEPS += $$OUT_PWD/../opennn/libopennn.a
# OpenMP library

include(../opennmp.pri)

115 changes: 97 additions & 18 deletions blank/main.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// OpenNN: Open Neural Networks Library
// www.opennn.net
//
// I R I S P L A N T A P P L I C A T I O N
// B L A N K A P P L I C A T I O N
//
// Artificial Intelligence Techniques SL (Artelnics)
// Artificial Intelligence Techniques SL
// [email protected]


#include <iostream>
#include <fstream>
#include <sstream>
Expand All @@ -15,14 +16,17 @@

#include "../opennn/opennn.h"


using namespace std;
using namespace opennn;
using namespace std::chrono;
using namespace Eigen;

int main()
{
try
{
cout << "OpenNN. Blank project." << endl;
cout << "OpenNN. ViT Example." << endl;

Eigen::Tensor<float, 4> input(1, 1, 1, 1);
input.setRandom();
Expand All @@ -44,23 +48,98 @@ int main()
const Index inputs_number = get_random_index(1, 10);
const Index targets_number = get_random_index(1, 10);
const Index neurons_number = get_random_index(1, 10);
// Index a = 0;
// Index b = 0;
// Tensor<bool, 0> truefalse = a == b;
// cout<<truefalse<<endl;
// throw runtime_error("Stop");
// srand(static_cast<unsigned>(time(nullptr)));

// // Data set

// ImageDataSet image_data_set;

// image_data_set.set_data_source_path("/home/artelnics/Escritorio/andres_alonso/ViT/dataset/bmp/cifar10_bmp1");

// image_data_set.read_bmp();

// vector<string> completion_vocabulary = language_data_set.get_completion_vocabulary();
// vector<string> context_vocabulary = language_data_set.get_context_vocabulary();

// // Neural network

// const Index input_length = image_data_set.get_samples_number();
// const Index number_labels = image_data_set.get_variables_number(DataSet::VariableUse::Target);
// const Index number_channels = image_data_set.get_channels_number();
// const Index height = image_data_set.get_image_height();
// const Index width = image_data_set.get_image_width();

// Index number_of_layers = 1;
// Index depth = 64;
// Index perceptron_depth = 128;
// Index heads_number = 4;



// Transformer transformer({ input_length, context_length, inputs_dimension, context_dimension,
// depth, perceptron_depth, heads_number, number_of_layers });

// transformer.set_model_type_string("TextClassification");
// transformer.set_dropout_rate(0);

// cout << "Total number of parameters: " << transformer.get_parameters_number() << endl;

// transformer.set_input_vocabulary(completion_vocabulary);
// transformer.set_context_vocabulary(context_vocabulary);

// // Training strategy

// TrainingStrategy training_strategy(&transformer, &language_data_set);

DataSet data_set(samples_number, { inputs_number }, { targets_number });
data_set.set_data_random();
data_set.set(DataSet::SampleUse::Training);

//Batch batch(samples_number, &data_set);
/*
batch.fill(data_set.get_sample_indices(DataSet::SampleUse::Training),
data_set.get_variable_indices(DataSet::VariableUse::Input),
data_set.get_variable_indices(DataSet::VariableUse::Target));
/*
NeuralNetwork neural_network(NeuralNetwork::ModelType::Approximation,
{ inputs_number }, { neurons_number }, { targets_number });
// training_strategy.set_loss_method(TrainingStrategy::LossMethod::CROSS_ENTROPY_ERROR_3D);

neural_network.set_parameters_random();
// training_strategy.get_loss_index()->set_regularization_method(LossIndex::RegularizationMethod::NoRegularization);

ForwardPropagation forward_propagation(samples_number, &neural_network);
// training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::ADAPTIVE_MOMENT_ESTIMATION);

// training_strategy.get_adaptive_moment_estimation()->set_custom_learning_rate(depth);

// training_strategy.get_adaptive_moment_estimation()->set_loss_goal(0.99);
// training_strategy.get_adaptive_moment_estimation()->set_maximum_epochs_number(4000);
// training_strategy.get_adaptive_moment_estimation()->set_maximum_time(237600);
// training_strategy.get_adaptive_moment_estimation()->set_batch_samples_number(64);

// training_strategy.get_adaptive_moment_estimation()->set_display(true);
// training_strategy.get_adaptive_moment_estimation()->set_display_period(1);

// TrainingResults training_results = training_strategy.perform_training();

// const TestingAnalysis testing_analysis(&transformer, &language_data_set);

// pair<type, type> transformer_error_accuracy = testing_analysis.test_transformer();

// cout << "TESTING ANALYSIS:" << endl;
// cout << "Testing error: " << transformer_error_accuracy.first << endl;
// cout << "Testing accuracy: " << transformer_error_accuracy.second << endl;

// // // Save results-

// // transformer.save("/home/artelnics/Escritorio/andres_alonso/ViT/ENtoES_model.xml");

// // // Testing analysis

// // transformer.load("/home/artelnics/Escritorio/andres_alonso/ViT/Weights/ENtoES_model.xml");

// // const TestingAnalysis testing_analysis(&transformer, &language_data_set);

// // pair<type, type> transformer_error_accuracy = testing_analysis.test_transformer();

// // cout << "TESTING ANALYSIS:" << endl;
// // cout << "Testing error: " << transformer_error_accuracy.first << endl;
// // cout << "Testing accuracy: " << transformer_error_accuracy.second << endl;


// ForwardPropagation forward_propagation(samples_number, &neural_network);

// neural_network.forward_propagate(batch.get_input_pairs(), forward_propagation, true);

Expand All @@ -70,7 +149,7 @@ int main()

// BackPropagation back_propagation(samples_number, &normalized_squared_error);
// normalized_squared_error.back_propagate(batch, forward_propagation, back_propagation);
*/

cout << "Bye!" << endl;

return 0;
Expand Down
56 changes: 43 additions & 13 deletions examples/airfoil_self_noise/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,31 @@ int main()

cout << "Airfoil self noise" << endl;


// DataSet data_set(1, { 1 }, { 1 });

// NeuralNetwork neural_network(NeuralNetwork::ModelType::Approximation, { 1 }, { 1 }, { 1 });

// TrainingStrategy training_strategy(&neural_network, &data_set);


// NeuralNetwork neural_network;
// neural_network.add_layer(make_unique<PerceptronLayer>(dimensions{2}, dimensions{2}, PerceptronLayer::ActivationFunction::HyperbolicTangent));
// neural_network.set_parameters_constant(10);

// Tensor<type, 2> inputs(2,2);
// inputs.setConstant(0);

// neural_network.print();

// neural_network.calculate_outputs(inputs);


// Data set

Tensor<type, 2> a(100, 100);


// Data set

DataSet data_set("C:/airfoil_self_noise.csv", ";", true);
Expand All @@ -49,18 +72,24 @@ int main()
// Training strategy

TrainingStrategy training_strategy(&neural_network, &data_set);

// training_strategy.set_display(false);

training_strategy.set_loss_method(TrainingStrategy::LossMethod::MEAN_SQUARED_ERROR);
//training_strategy.set_loss_method(TrainingStrategy::LossMethod::NORMALIZED_SQUARED_ERROR);
//training_strategy.set_loss_method(TrainingStrategy::LossMethod::MINKOWSKI_ERROR); // @todo gives 0.56

//training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::QUASI_NEWTON_METHOD);
//training_strategy.print();

//training_strategy.set_loss_method(TrainingStrategy::LossMethod::MEAN_SQUARED_ERROR);
//training_strategy.set_loss_method(TrainingStrategy::LossMethod::NORMALIZED_SQUARED_ERROR);
//training_strategy.set_loss_method(TrainingStrategy::LossMethod::SUM_SQUARED_ERROR);
// training_strategy.set_loss_method(TrainingStrategy::LossMethod::MEAN_SQUARED_ERROR);
training_strategy.set_loss_method(TrainingStrategy::LossMethod::MINKOWSKI_ERROR); // @todo gives 0.56

training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::QUASI_NEWTON_METHOD);
//training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::CONJUGATE_GRADIENT);
training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::LEVENBERG_MARQUARDT_ALGORITHM); //Fail-Mean Squared error / Doesnt work with MINKOWSKI_ERROR / is not implemented yet with weighted squared error
//training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::STOCHASTIC_GRADIENT_DESCENT);
//training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::ADAPTIVE_MOMENT_ESTIMATION);
// training_strategy.set_optimization_method(TrainingStrategy::OptimizationMethod::ADAPTIVE_MOMENT_ESTIMATION);


training_strategy.get_Levenberg_Marquardt_algorithm()->set_maximum_epochs_number(1);

Expand All @@ -86,18 +115,18 @@ int main()
// neural_network.save("../opennn/examples/airfoil_self_noise/data/neural_network.xml");
// neural_network.save_expression_c("../opennn/examples/airfoil_self_noise/data/airfoil_self_noise.c");
// Deploy
// // Deploy
NeuralNetwork new_neural_network("../opennn/examples/airfoil_self_noise/data/neural_network.xml");
// NeuralNetwork new_neural_network("../opennn/examples/airfoil_self_noise/data/neural_network.xml");
Tensor<type, 2> inputs(1, input_variables_number);
inputs.setRandom();
// Tensor<type, 2> inputs(1, input_variables_number);
// inputs.setRandom();
inputs.setValues({{type(800), type(0), type(0.3048), type(71.3), type(0.00266337)}});
// inputs.setValues({{type(800), type(0), type(0.3048), type(71.3), type(0.00266337)}});
cout << inputs << endl;
// cout << inputs << endl;
const Tensor<type, 2> outputs = new_neural_network.calculate_outputs(inputs);
// const Tensor<type, 2> outputs = new_neural_network.calculate_outputs(inputs);
// cout << outputs << endl;
Expand All @@ -113,6 +142,7 @@ int main()
neural_network.print();
*/

cout << "Good bye!" << endl;

return 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/amazon_reviews/data/amazon_cells_reduced.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'So there is no way for me to plug it in here in the US unless I go by a converter. Bad
So there is no way for me to plug it in here in the US unless I go by a converter. Bad
Good case, Excellent value. Good
Great for the jawbone. Good
Tied to charger for conversations lasting more than 45 minutes.MAJOR PROBLEMS!! Bad
Expand Down
Binary file modified examples/amazon_reviews/data/amazon_cells_reduced_data.txt
Binary file not shown.
Loading

0 comments on commit d2d7982

Please sign in to comment.