How to use the clifford.tools.g3c.cost_functions.object_set_cost_sum function in clifford

To help you get started, we’ve selected a few clifford examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pygae / clifford / clifford / tools / g3c / rotor_estimation.py View on Github external
symmetric=symmetric)

    res = minimize(minimisation_func, x0, method='SLSQP', options={'ftol': 10.0 ** (-16),
                                                                   'maxiter': 1000,
                                                                   'disp': False})
    if print_res:
        print(res)
    res = minimize(minimisation_func, res.x, method='L-BFGS-B', options={'ftol': 10.0**(-16),
                                                                         'maxiter': 1000,
                                                                         'disp': False,
                                                                         'maxls': 40})
    if print_res:
        print(res)
    rotor = rotorconversion(res.x)
    query_model_remapped = [normalised((apply_rotor(l, rotor))(grade_list[i])) for i, l in enumerate(query_model)]
    cost = object_set_cost_sum(reference_model, query_model_remapped, object_type=object_type, motor=motor,
                               symmetric=symmetric)
    return rotor, cost
github pygae / clifford / clifford / tools / g3c / rotor_estimation.py View on Github external
if objects_per_sample is None:
        objects_per_sample = max(int(len(query_model)/10), 5)
    min_cost = np.finfo(float).max
    min_rotor = 1.0 + 0.0 * e1
    for i in range(n_repeats):
        indices = random.sample(range(len(reference_model)), objects_per_sample)
        object_sample_reference = [reference_model[j] for j in indices]
        object_sample_query = [query_model[j] for j in indices]
        try:
            rotor, e_flag = sequential_object_rotor_estimation(object_sample_reference, object_sample_query,
                                                               object_type=object_type)
        except Exception:
            rotor = 1.0 + 0*e1
            print('ERROR')
        query_model_remapped = [normalised(apply_rotor(l, rotor)) for l in object_sample_query]
        new_cost = object_set_cost_sum(reference_model, query_model_remapped, object_type=object_type)
        if new_cost < min_cost:
            min_cost = new_cost
            min_rotor = rotor
        # print('SAMPLE: ', i, '  cost  ', min_cost)
    return min_rotor, min_cost
github pygae / clifford / clifford / tools / g3c / rotor_estimation.py View on Github external
def minimisation_func(x):
        R = rotorconversion(x)
        query_model_remapped = [normalised((apply_rotor(l, R))(grade_list[i])) for i, l in enumerate(query_model)]
        return object_set_cost_sum(reference_model, query_model_remapped,
                                   object_type=object_type, motor=motor,
                                   symmetric=symmetric)