Neural animation tweaks
This commit is contained in:
parent
63e2d226d2
commit
a11c5d7c39
1 changed files with 5 additions and 9 deletions
|
|
@ -682,7 +682,7 @@ struct animation_2d_app
|
||||||
std::size_t train_iterations = 0;
|
std::size_t train_iterations = 0;
|
||||||
std::size_t const max_train_iterations = 1024*8;
|
std::size_t const max_train_iterations = 1024*8;
|
||||||
float const randomize_amplitude = 10.f;
|
float const randomize_amplitude = 10.f;
|
||||||
static constexpr auto mutation_amplitude = [](float t){ return 10.f * geom::lerp(1.f, 0.01f, t); };
|
static constexpr auto mutation_amplitude = [](float t){ return std::pow(10.f, 1.f + geom::lerp(0.f, -2.f, t)); };
|
||||||
|
|
||||||
float best_score = 0.f;
|
float best_score = 0.f;
|
||||||
bool const warm_start = false;
|
bool const warm_start = false;
|
||||||
|
|
@ -1200,18 +1200,14 @@ void animation_2d_app::do_train()
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::pair<float, std::size_t>> scores(population.size());
|
std::vector<std::pair<float, std::size_t>> scores(population.size());
|
||||||
std::atomic<std::size_t> finished_count{0};
|
std::vector<async::future<void>> futures;
|
||||||
for (std::size_t i = 0; i < population.size(); ++i)
|
for (std::size_t i = 0; i < population.size(); ++i)
|
||||||
{
|
{
|
||||||
bg.dispatch([&, i, rng = rng]() mutable {
|
futures.push_back(bg.dispatch([&, i, rng = rng]() mutable {
|
||||||
scores[i] = {eval_score(population[i], rng), i};
|
scores[i] = {eval_score(population[i], rng), i};
|
||||||
++finished_count;
|
}));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
bg.wait();
|
bg.wait_all(futures.begin(), futures.end()).get();
|
||||||
|
|
||||||
if (finished_count.load() != population.size())
|
|
||||||
throw std::runtime_error("bg.wait() didn't wait for all tasks to finish");
|
|
||||||
|
|
||||||
std::sort(scores.begin(), scores.end(), [](auto const & p1, auto const & p2){ return p1.first > p2.first; });
|
std::sort(scores.begin(), scores.end(), [](auto const & p1, auto const & p2){ return p1.first > p2.first; });
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue