@@ -217,14 +205,14 @@ static PyObject* PyBobMachineActivation_call2(PyBobMachineActivationObject* o,
for(Py_ssize_ti=0;i<z->ndim;++i){
if(z->shape[i]!=res->shape[i]){
PyErr_Format(PyExc_RuntimeError,"Input and output arrays should have matching sizes, but dimension %"PY_FORMAT_SIZE_T"d of input array `z' has %"PY_FORMAT_SIZE_T"d positions while output array `res' has %"PY_FORMAT_SIZE_T"d positions",z->shape[i],res->shape[i]);
PyErr_Format(PyExc_RuntimeError,"Input and output arrays should have matching sizes, but dimension %"PY_FORMAT_SIZE_T"d of input array `z' has %"PY_FORMAT_SIZE_T"d positions while output array `res' has %"PY_FORMAT_SIZE_T"d positions",i,z->shape[i],res->shape[i]);
return0;
}
}
//at this point all checks are done, we can proceed into calling C++
PyErr_Format(PyExc_RuntimeError,"number of arguments mismatch - %s requires 1 or 2 arguments, but you provided %"PY_FORMAT_SIZE_T"d (see help)",s_call_str,nargs);
}
return0;
}
PyDoc_STRVAR(s_f_prime_str,"f_prime");
PyDoc_STRVAR(s_f_prime_doc,
"o.f_prime(z, [res]) -> array | scalar\n\
\n\
Computes the derivative of the activated value, given an input\n\
array or scalar ``z``, placing results in ``res`` (and returning\n\
it).\n\
\n\
If ``z`` is an array, then you can pass another array in ``res``\n\
to store the results and, in this case, we won't allocate a new\n\
one for that purpose. This can be a speed-up in certain scenarios.\n\
Note this does not work for scalars as it makes little sense to\n\
avoid scalar allocation at this level.\n\
\n\
If you decide to pass an array in ``res``, note this array should\n\
have the exact same dimensions as the input array ``z``. It is an\n\
error otherwise.\n\
\n\
.. note::\n\
\n\
This method only accepts 64-bit float arrays as input or\n\
PyErr_Format(PyExc_RuntimeError,"number of arguments mismatch - %s requires 1 or 2 arguments, but you provided %"PY_FORMAT_SIZE_T"d (see help)",s_call_str,nargs);
.def("__call__", &activation_f_ndarray_1, (arg("self"), arg("z"), arg("res")), "Computes the activated value, given an input array ``z``, placing results in ``res`` (and returning it)")
.def("__call__", &activation_f_ndarray_2, (arg("self"), arg("z")), "Computes the activated value, given an input array ``z``. Returns a newly allocated array with the same size as ``z``")
.def("__call__", &bob::machine::Activation::f, (arg("self"), arg("z")), "Computes the activated value, given an input ``z``")
.def("f_prime", &activation_f_prime_ndarray_1, (arg("self"), arg("z"), arg("res")), "Computes the derivative of the activated value, placing results in ``res`` (and returning it)")
.def("f_prime", &activation_f_prime_ndarray_2, (arg("self"), arg("z")), "Computes the derivative of the activated value, given an input array ``z``. Returns a newly allocated array with the same size as ``z``")
.def("f_prime", &bob::machine::Activation::f_prime, (arg("self"), arg("z")), "Computes the derivative of the activated value.")
.def("f_prime_from_f", &activation_f_prime_from_f_ndarray_1, (arg("self"), arg("a"), arg("res")), "Computes the derivative of the activated value, given **the activated value** ``a``, placing results in ``res`` (and returning it)")
.def("f_prime_from_f", &activation_f_prime_from_f_ndarray_2, (arg("self"), arg("z")), "Computes the derivative of the activated value, given **the activated value** ``a``. Returns a newly allocated array with the same size as ``a`` with the answer.")
.def("f_prime_from_f", &bob::machine::Activation::f_prime_from_f, (arg("self"), arg("a")), "Computes the derivative of the activation value, given **the activated value** ``a``.")