where函数是numpy的内置,也是一个非常有用的函数,提供了快速并且灵活的计算功能。 def f_norm_1(data, estimate): residule = 0 for row_index in range(data.shape[0]): for column_index in range(data.shape[1]): if data[row_index][column_index] != 0: residule += (data[row_index][column_...
def vector_angle(u, v, direction=None): ''' vector_angle(u, v) yields the angle between the two vectors u and v. The optional argument direction is by default None, which specifies that the smallest possible angle between the vectors be reported; if the vectors u and v are 2D vectors...
def generate_f_score_gate( neg_smaple, pos_sample, chan, beta=1, theta=2, high=True): """ given a negative and a positive sample, calculate the 'optimal' threshold gate position from aproximate f-score calculation """ neg_hist, bins = numpy.histogram(neg_smaple[:, chan], 1000, ...
def l2_batch_normalize(x, epsilon=1e-12, scope=None): """ Helper function to normalize a batch of vectors. :param x: the input placeholder :param epsilon: stabilizes division :return: the batch of l2 normalized vector """ with tf.name_scope(scope, "l2_batch_normalize") as scope: x...
diff(a, n=1, axis=-1) Calculate the n-th discrete difference along given axis. ediff1d(ary[, to_end, to_begin]) The differences between consecutive elements of an array. function not implemented gradient(f, *varargs, **kwargs) Return the gradient of an N-dimensional array. function no...
# intersect manifold with vantage vectors # calculate distance dist_A_alpha = dist_A dist_B_alpha = dist_B # calculate lambda # sinusoid taking as input the angle between vantage and line AB (separating the two targets) line_AB = np3_to_vector3(PAB).perpendicular() angle_A = py_ang...