Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,63 @@ set_tests_properties(test_simd_optimization PROPERTIES
TIMEOUT 120
LABELS "simd;performance"
)

# Test 10: Training functions - triplet_parallel
# Tests the default triplet_parallel function
add_test(
NAME test_func_triplet_parallel
COMMAND NNets -c ${CMAKE_SOURCE_DIR}/configs/test_funcs_triplet.json -t
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(test_func_triplet_parallel PROPERTIES
TIMEOUT 120
LABELS "training_funcs;triplet"
)

# Test 11: Training functions - exhaustive_full_parallel
# Tests the exhaustive search function
add_test(
NAME test_func_exhaustive_parallel
COMMAND NNets -c ${CMAKE_SOURCE_DIR}/configs/test_funcs_exhaustive.json -t
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(test_func_exhaustive_parallel PROPERTIES
TIMEOUT 180
LABELS "training_funcs;exhaustive"
)

# Test 12: Training functions - random_pair_ext_parallel
# Tests the random pair generation function
add_test(
NAME test_func_random_pair_parallel
COMMAND NNets -c ${CMAKE_SOURCE_DIR}/configs/test_funcs_random_pair.json -t
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(test_func_random_pair_parallel PROPERTIES
TIMEOUT 120
LABELS "training_funcs;random_pair"
)

# Test 13: Training functions - sequence of multiple functions
# Tests using multiple functions in sequence with error checking after each
add_test(
NAME test_func_sequence
COMMAND NNets -c ${CMAKE_SOURCE_DIR}/configs/test_funcs_sequence.json -t
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(test_func_sequence PROPERTIES
TIMEOUT 180
LABELS "training_funcs;sequence"
)

# Test 14: List available training functions
# Tests the --list-funcs command
add_test(
NAME test_list_funcs
COMMAND NNets --list-funcs
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
set_tests_properties(test_list_funcs PROPERTIES
TIMEOUT 10
LABELS "training_funcs;help"
)
10 changes: 10 additions & 0 deletions configs/test_funcs_exhaustive.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"receptors": 10,
"classes": [
{ "id": 0, "word": "" },
{ "id": 1, "word": "x" }
],
"generate_shifts": false,
"funcs": ["exhaustive_last_parallel", "triplet_parallel"],
"description": "Test config for exhaustive search - uses exhaustive_last_parallel followed by triplet_parallel for convergence"
}
10 changes: 10 additions & 0 deletions configs/test_funcs_random_pair.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"receptors": 10,
"classes": [
{ "id": 0, "word": "" },
{ "id": 1, "word": "x" }
],
"generate_shifts": false,
"funcs": ["random_pair_ext_parallel", "random_pair_ext_parallel", "random_pair_ext_parallel", "triplet_parallel"],
"description": "Test config for random_pair_ext_parallel function, followed by triplet_parallel to ensure convergence"
}
10 changes: 10 additions & 0 deletions configs/test_funcs_sequence.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"receptors": 10,
"classes": [
{ "id": 0, "word": "" },
{ "id": 1, "word": "x" }
],
"generate_shifts": false,
"funcs": ["random_from_inputs", "random_pair_opt_parallel", "triplet_parallel"],
"description": "Test config for multiple functions in sequence - error checked after each"
}
10 changes: 10 additions & 0 deletions configs/test_funcs_triplet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"receptors": 20,
"classes": [
{ "id": 0, "word": "" },
{ "id": 1, "word": "test" }
],
"generate_shifts": false,
"funcs": ["triplet_parallel"],
"description": "Test config for triplet_parallel function"
}
24 changes: 24 additions & 0 deletions include/json_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
#ifndef JSON_IO_H
#define JSON_IO_H

// ============================================================================
// Глобальные переменные для конфигурации функций обучения
// ============================================================================

// Список имён функций обучения из конфига (пустой = использовать функцию по умолчанию)
std::vector<std::string> g_trainingFuncs;

// ============================================================================
// Функции загрузки конфигурации
// ============================================================================
Expand Down Expand Up @@ -144,13 +151,30 @@ bool loadConfig(const string& configPath, int& receptors) {
}
}

// Загружаем последовательность функций обучения (если задана)
g_trainingFuncs.clear();
if (config.contains("funcs")) {
for (const auto& func : config["funcs"]) {
string funcName = func.get<string>();
g_trainingFuncs.push_back(funcName);
}
}

cout << "Loaded config: " << configPath << endl;
cout << " Receptors: " << receptors << endl;
cout << " Classes: " << Classes << endl;
cout << " Images: " << const_words.size() << endl;
if (config.contains("description")) {
cout << " Description: " << config["description"].get<string>() << endl;
}
if (!g_trainingFuncs.empty()) {
cout << " Training funcs: ";
for (size_t i = 0; i < g_trainingFuncs.size(); i++) {
if (i > 0) cout << ", ";
cout << g_trainingFuncs[i];
}
cout << endl;
}

return true;
}
Expand Down
Loading