Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
RoberLopez committed Dec 3, 2024
1 parent 5d5ac42 commit a3c95ea
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 32 deletions.
14 changes: 5 additions & 9 deletions opennn/batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ void Batch::fill(const vector<Index>& sample_indices,

ImageDataSet* image_data_set = dynamic_cast<ImageDataSet*>(data_set);

if (image_data_set && image_data_set->get_augmentation())
if(image_data_set && image_data_set->get_augmentation())
{
ImageDataSet* image_data_set = static_cast<ImageDataSet*>(data_set);
/*
// @TODO
Tensor<type, 2>& augmented_data = perform_augmentation(data);
Expand Down Expand Up @@ -154,7 +153,6 @@ void Batch::set(const Index& new_batch_size, DataSet* new_data_set)
if(data_set_target_dimensions.size() == 1)
{
target_dimensions = {{batch_size, target_variables_number}};

target_tensor.resize(batch_size*target_variables_number);
}
else if(data_set_target_dimensions.size() == 2)
Expand Down Expand Up @@ -272,18 +270,16 @@ bool Batch::has_context() const

vector<pair<type*, dimensions>> Batch::get_input_pairs() const
{
vector<pair<type*, dimensions>> input_pairs(has_context() ? 2 : 1);
vector<pair<type*, dimensions>> input_pairs = {{(type*)input_tensor.data(), input_dimensions}};

input_pairs[0] = { (type*)input_tensor.data(), input_dimensions};

if (has_context())
input_pairs[1] = { (type*)context_tensor.data(), context_dimensions};
input_pairs.push_back({(type*)context_tensor.data(), context_dimensions});

return input_pairs;
}


pair<type*, dimensions> Batch::get_targets_pair() const
pair<type*, dimensions> Batch::get_target_pair() const
{
return { (type*)target_tensor.data() , target_dimensions};
}
Expand Down
2 changes: 1 addition & 1 deletion opennn/batch.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct Batch

vector<pair<type*, dimensions>> get_input_pairs() const;

pair<type*, dimensions> get_targets_pair() const;
pair<type*, dimensions> get_target_pair() const;

Index get_batch_samples_number() const;

Expand Down
8 changes: 4 additions & 4 deletions opennn/cross_entropy_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void CrossEntropyError::calculate_binary_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down Expand Up @@ -70,7 +70,7 @@ void CrossEntropyError::calculate_multiple_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down Expand Up @@ -121,7 +121,7 @@ void CrossEntropyError::calculate_binary_output_delta(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down Expand Up @@ -149,7 +149,7 @@ void CrossEntropyError::calculate_multiple_output_delta(const Batch& batch,
{
const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down
2 changes: 1 addition & 1 deletion opennn/cross_entropy_error_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void CrossEntropyError3D::calculate_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const Index outputs_number = targets_pair.second[1];

Expand Down
16 changes: 5 additions & 11 deletions opennn/data_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4229,21 +4229,15 @@ void DataSet::check_separators(const string& line) const

bool DataSet::has_binary_raw_variables() const
{
for (const auto& raw_variable : raw_variables)
if (raw_variable.type == RawVariableType::Binary)
return true;

return false;
return any_of(raw_variables.begin(), raw_variables.end(),
[](const RawVariable& raw_variable) { return raw_variable.type == RawVariableType::Binary; });
}


bool DataSet::has_categorical_raw_variables() const
{
for (const auto& raw_variable : raw_variables)
if (raw_variable.type == RawVariableType::Categorical)
return true;

return false;
{
return any_of(raw_variables.begin(), raw_variables.end(),
[](const RawVariable& raw_variable) { return raw_variable.type == RawVariableType::Categorical; });
}


Expand Down
2 changes: 1 addition & 1 deletion opennn/loss_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void LossIndex::calculate_errors_lm(const Batch& batch,

const TensorMap<Tensor<type, 2>> outputs = tensor_map_2(outputs_pair);

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down
2 changes: 1 addition & 1 deletion opennn/mean_squared_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void MeanSquaredError::calculate_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down
2 changes: 1 addition & 1 deletion opennn/minkowski_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void MinkowskiError::calculate_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down
2 changes: 1 addition & 1 deletion opennn/normalized_squared_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void NormalizedSquaredError::calculate_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down
4 changes: 2 additions & 2 deletions opennn/weighted_squared_error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ void WeightedSquaredError::calculate_error(const Batch& batch,

const Index batch_samples_number = batch.get_batch_samples_number();

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down Expand Up @@ -329,7 +329,7 @@ void WeightedSquaredError::calculate_squared_errors_lm(const Batch& batch,
{
// Batch

const pair<type*, dimensions> targets_pair = batch.get_targets_pair();
const pair<type*, dimensions> targets_pair = batch.get_target_pair();

const TensorMap<Tensor<type, 2>> targets = tensor_map_2(targets_pair);

Expand Down

0 comments on commit a3c95ea

Please sign in to comment.