Skip to content

Commit

Permalink
fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
elegoiria committed Jan 20, 2025
2 parents ff9fcb1 + e3c55ca commit 4324405
Show file tree
Hide file tree
Showing 51 changed files with 672 additions and 889 deletions.
2 changes: 1 addition & 1 deletion examples/airfoil_self_noise/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int main()

ModelSelection model_selection(&training_strategy);

model_selection.perform_inputs_selection();
model_selection.perform_input_selection();
/*
// Testing analysis
Expand Down
24 changes: 11 additions & 13 deletions examples/mnist/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,20 @@ int main()

const Index samples_number = 3;

const Index image_height = 4;
const Index image_width = 4;
const Index channels = 1;
const Index targets = 2;
const Index image_height = 3;
const Index image_width = 3;
const Index channels = 3;
const Index targets = 3;

//ImageDataSet image_data_set(samples_number, {image_height, image_width, channels}, {targets});

//image_data_set.set_data_random();

//image_data_set.set(DataSet::SampleUse::Training);

ImageDataSet image_data_set(0,{0,0,0},{0});

//image_data_set.set_data_path("data");
image_data_set.set_data_path("C:/mnist/train");
//image_data_set.set_data_path("C:/binary_mnist");
//image_data_set.set_data_path("C:/mnist/train");
image_data_set.set_data_path("C:/binary_mnist");
//image_data_set.set_data_path("C:/Users/Roberto Lopez/Documents/opennn/examples/mnist/data");
//image_data_set.set_data_path("C:/melanoma_dataset_bmp");
//image_data_set.set_data_path("C:/melanoma_dataset_bmp_small");
Expand All @@ -51,14 +49,14 @@ int main()

image_data_set.read_bmp();

//image_data_set.set(DataSet::SampleUse::Training);

// Neural network

NeuralNetwork neural_network(NeuralNetwork::ModelType::ImageClassification,
image_data_set.get_input_dimensions(),
{ 32 },
image_data_set.get_target_dimensions());

//neural_network.print();
image_data_set.get_dimensions(DataSet::VariableUse::Input),
{ 8 },
image_data_set.get_dimensions(DataSet::VariableUse::Target));

// Training strategy

Expand Down
22 changes: 11 additions & 11 deletions opennn/adaptive_moment_estimation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,15 @@ TrainingResults AdaptiveMomentEstimation::perform_training()
const Index training_samples_number = data_set->get_samples_number(DataSet::SampleUse::Training);
const Index selection_samples_number = data_set->get_samples_number(DataSet::SampleUse::Selection);

const vector<Descriptives> input_variables_descriptives = data_set->scale_variables(DataSet::VariableUse::Input);

const Index training_batch_samples_number = min(training_samples_number, batch_samples_number);

const Index selection_batch_samples_number = (selection_samples_number != 0)
? min(selection_samples_number, batch_samples_number)
: 0;

Batch training_batch(training_batch_samples_number, data_set);

Batch selection_batch(selection_batch_samples_number, data_set);

const Index training_batches_number = (training_batch_samples_number != 0)
Expand Down Expand Up @@ -253,15 +254,14 @@ TrainingResults AdaptiveMomentEstimation::perform_training()
//cout << "Iteration " << iteration << "/" << training_batches_number << endl;

// Data set
training_batch.fill(training_batches[iteration],
input_variable_indices,
decoder_variable_indices,
target_variable_indices);



training_batch.fill(training_batches[iteration],
input_variable_indices,
decoder_variable_indices,
target_variable_indices);

// Neural network

neural_network->forward_propagate(training_batch.get_input_pairs(),
training_forward_propagation,
is_training);
Expand All @@ -276,6 +276,7 @@ TrainingResults AdaptiveMomentEstimation::perform_training()

//cout << "gradient:\n" << training_back_propagation.gradient << endl;
//cout << "numerical gradient:\n" << numerical_gradient<< endl;

//cout << "gradient - numerical gradient :\n" << training_back_propagation.gradient - numerical_gradient << endl;

//cout << "numerical input derivatives:\n" << loss_index->calculate_numerical_inputs_derivatives() << endl;
Expand All @@ -291,7 +292,7 @@ TrainingResults AdaptiveMomentEstimation::perform_training()
//if(display && epoch % display_period == 0)
// display_progress_bar(iteration, training_batches_number - 1);
}

// Loss

training_error /= type(training_batches_number);
Expand All @@ -300,7 +301,7 @@ TrainingResults AdaptiveMomentEstimation::perform_training()
training_accuracy /= type(training_batches_number);

results.training_error_history(epoch) = training_error;

if(has_selection)
{
selection_batches = data_set->get_batches(selection_samples_indices, selection_batch_samples_number, shuffle);
Expand All @@ -310,7 +311,6 @@ TrainingResults AdaptiveMomentEstimation::perform_training()

for(Index iteration = 0; iteration < selection_batches_number; iteration++)
{

// Data set

selection_batch.fill(selection_batches[iteration],
Expand Down
36 changes: 21 additions & 15 deletions opennn/batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "batch.h"
#include "tensors.h"
#include "image_data_set.h"
#include "language_data_set.h"
#include "images.h"

namespace opennn
Expand All @@ -23,24 +24,31 @@ void Batch::fill(const vector<Index>& sample_indices,

if(is_instance_of<ImageDataSet>(data_set))
{
// @todo
//ImageDataSet* image_data_set = dynamic_cast<ImageDataSet*>(data_set);
ImageDataSet* image_data_set = dynamic_cast<ImageDataSet*>(data_set);

//image_data_set && image_data_set->get_augmentation())

//Tensor<type, 2> augmented_data = perform_augmentation(data);
if (image_data_set->get_augmentation())
{
// @todo

//fill_tensor_data(augmented_data, sample_indices, input_indices, input_data);
//Tensor<type, 2> augmented_data = perform_augmentation(data);

//fill_tensor_data(augmented_data, sample_indices, input_indices, input_data);
}
else
{
fill_tensor_data(data, sample_indices, input_indices, input_tensor.data());
}
}
else
{
fill_tensor_data(data, sample_indices, input_indices, input_tensor.data());
}

fill_tensor_data(data, sample_indices, decoder_indices, decoder_tensor.data());
if (is_instance_of<LanguageDataSet>(data_set))
fill_tensor_data(data, sample_indices, decoder_indices, decoder_tensor.data());

fill_tensor_data(data, sample_indices, target_indices, target_tensor.data());

}


Expand Down Expand Up @@ -174,9 +182,7 @@ void Batch::print() const
<< "Input dimensions:" << endl;

print_vector(input_dimensions);


/*

if(input_dimensions.size() == 4)
{
const TensorMap<Tensor<type, 4>> inputs((type*)input_tensor.data(),
Expand All @@ -187,7 +193,7 @@ void Batch::print() const

cout << inputs << endl;
}
*/


cout << "Decoder:" << endl
<< "Decoder dimensions:" << endl;
Expand All @@ -199,11 +205,11 @@ void Batch::print() const

print_vector(target_dimensions);

// const TensorMap<Tensor<type, 2>> targets((type*)target_tensor.data(),
// target_dimensions[0],
// target_dimensions[1]);
const TensorMap<Tensor<type, 2>> targets((type*)target_tensor.data(),
target_dimensions[0],
target_dimensions[1]);

// cout << targets << endl;
cout << targets << endl;

}

Expand Down
4 changes: 2 additions & 2 deletions opennn/conjugate_gradient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ TrainingResults ConjugateGradient::perform_training()
}

Batch training_batch(training_samples_number, data_set);
training_batch.fill(training_samples_indices, input_variable_indices, target_variable_indices);
training_batch.fill(training_samples_indices, input_variable_indices, {}, target_variable_indices);

Batch selection_batch(selection_samples_number, data_set);
selection_batch.fill(selection_samples_indices, input_variable_indices, target_variable_indices);
selection_batch.fill(selection_samples_indices, input_variable_indices, {}, target_variable_indices);

ForwardPropagation training_forward_propagation(training_samples_number, neural_network);
ForwardPropagation selection_forward_propagation(selection_samples_number, neural_network);
Expand Down
Loading

0 comments on commit 4324405

Please # to comment.