Vector api tweaks.

This commit is contained in:
Relintai 2023-04-29 14:37:58 +02:00
parent 488cdde8c9
commit 8c15b12f6a
5 changed files with 15 additions and 15 deletions

View File

@ -29,7 +29,7 @@
<description>
</description>
</method>
<method name="add_mlpp_vector">
<method name="append_mlpp_vector">
<return type="void" />
<argument index="0" name="other" type="float" />
<description>

View File

@ -65,7 +65,7 @@ void MLPPGAN::gradient_descent(real_t learning_rate, int max_epoch, bool ui) {
Ref<MLPPVector> y_hat = model_set_test_discriminator(discriminator_input_set);
Ref<MLPPVector> output_set = alg.zerovecnv(_n);
Ref<MLPPVector> output_set_real = alg.onevecnv(_n);
output_set->add_mlpp_vector(output_set_real); // Fake + real output scores.
output_set->append_mlpp_vector(output_set_real); // Fake + real output scores.
ComputeDiscriminatorGradientsResult dgrads = compute_discriminator_gradients(y_hat, _output_set);

View File

@ -36,7 +36,7 @@ void MLPPVector::push_back(real_t p_elem) {
_data[_size - 1] = p_elem;
}
void MLPPVector::add_mlpp_vector(const Ref<MLPPVector> &p_other) {
void MLPPVector::append_mlpp_vector(const Ref<MLPPVector> &p_other) {
ERR_FAIL_COND(!p_other.is_valid());
int other_size = p_other->size();
@ -899,7 +899,7 @@ void MLPPVector::absb(const Ref<MLPPVector> &a) {
}
}
Ref<MLPPVector> MLPPVector::zero_vec(int n) const {
Ref<MLPPVector> MLPPVector::vecn_zero(int n) const {
Ref<MLPPVector> vec;
vec.instance();
@ -908,7 +908,7 @@ Ref<MLPPVector> MLPPVector::zero_vec(int n) const {
return vec;
}
Ref<MLPPVector> MLPPVector::one_vec(int n) const {
Ref<MLPPVector> MLPPVector::vecn_one(int n) const {
Ref<MLPPVector> vec;
vec.instance();
@ -917,7 +917,7 @@ Ref<MLPPVector> MLPPVector::one_vec(int n) const {
return vec;
}
Ref<MLPPVector> MLPPVector::full_vec(int n, int k) const {
Ref<MLPPVector> MLPPVector::vecn_full(int n, int k) const {
Ref<MLPPVector> vec;
vec.instance();
@ -1360,7 +1360,7 @@ void MLPPVector::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::POOL_REAL_ARRAY, "data"), "set_data", "get_data");
ClassDB::bind_method(D_METHOD("push_back", "elem"), &MLPPVector::push_back);
ClassDB::bind_method(D_METHOD("add_mlpp_vector", "other"), &MLPPVector::push_back);
ClassDB::bind_method(D_METHOD("append_mlpp_vector", "other"), &MLPPVector::append_mlpp_vector);
ClassDB::bind_method(D_METHOD("remove", "index"), &MLPPVector::remove);
ClassDB::bind_method(D_METHOD("remove_unordered", "index"), &MLPPVector::remove_unordered);
ClassDB::bind_method(D_METHOD("erase", "val"), &MLPPVector::erase);
@ -1450,9 +1450,9 @@ void MLPPVector::_bind_methods() {
ClassDB::bind_method(D_METHOD("absn"), &MLPPVector::absn);
ClassDB::bind_method(D_METHOD("absb", "a"), &MLPPVector::absb);
ClassDB::bind_method(D_METHOD("zero_vec", "n"), &MLPPVector::zero_vec);
ClassDB::bind_method(D_METHOD("one_vec", "n"), &MLPPVector::one_vec);
ClassDB::bind_method(D_METHOD("full_vec", "n", "k"), &MLPPVector::full_vec);
ClassDB::bind_method(D_METHOD("vecn_zero", "n"), &MLPPVector::vecn_zero);
ClassDB::bind_method(D_METHOD("vecn_one", "n"), &MLPPVector::vecn_one);
ClassDB::bind_method(D_METHOD("vecn_full", "n", "k"), &MLPPVector::vecn_full);
ClassDB::bind_method(D_METHOD("sin"), &MLPPVector::sin);
ClassDB::bind_method(D_METHOD("sinn"), &MLPPVector::sinn);

View File

@ -33,7 +33,7 @@ public:
}
void push_back(real_t p_elem);
void add_mlpp_vector(const Ref<MLPPVector> &p_other);
void append_mlpp_vector(const Ref<MLPPVector> &p_other);
void remove(real_t p_index);
@ -177,9 +177,9 @@ public:
Ref<MLPPVector> absn() const;
void absb(const Ref<MLPPVector> &a);
Ref<MLPPVector> zero_vec(int n) const;
Ref<MLPPVector> one_vec(int n) const;
Ref<MLPPVector> full_vec(int n, int k) const;
Ref<MLPPVector> vecn_zero(int n) const;
Ref<MLPPVector> vecn_one(int n) const;
Ref<MLPPVector> vecn_full(int n, int k) const;
void sin();
Ref<MLPPVector> sinn() const;

View File

@ -71,7 +71,7 @@ void MLPPWGAN::gradient_descent(real_t learning_rate, int max_epoch, bool ui) {
ly_hat = model_set_test_discriminator(discriminator_input_set);
loutput_set = alg.scalar_multiplynv(-1, alg.onevecnv(_n)); // WGAN changes y_i = 1 and y_i = 0 to y_i = 1 and y_i = -1
Ref<MLPPVector> output_set_real = alg.onevecnv(_n);
loutput_set->add_mlpp_vector(output_set_real); // Fake + real output scores.
loutput_set->append_mlpp_vector(output_set_real); // Fake + real output scores.
DiscriminatorGradientResult discriminator_gradient_results = compute_discriminator_gradients(ly_hat, loutput_set);
Vector<Ref<MLPPMatrix>> cumulative_discriminator_hidden_layer_w_grad = discriminator_gradient_results.cumulative_hidden_layer_w_grad;