-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,923 additions
and
779 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,4 +71,3 @@ else:unix: PRE_TARGETDEPS += $$OUT_PWD/../opennn/libopennn.a | |
# OpenMP library | ||
|
||
include(../opennmp.pri) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
@@ -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(); | ||
|
@@ -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); | ||
|
||
|
@@ -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; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.