Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Re map with our new rotor
remapped_objects = [apply_rotor(l, r_est).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects,
object_type=object_type, cuda=cuda)
current_cost = np.sum(costs)
print(i, current_cost, covergence_threshold)
if current_cost < min_global_cost:
min_global_cost = current_cost
min_global_rotor = +r_est
if current_cost < covergence_threshold:
return labels, costs, r_est
print('Finished iterations')
# Re map with our new rotor
remapped_objects = [apply_rotor(l, min_global_rotor).normal() for l in query_model]
# Get the new matching
print('Rematching')
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects, cuda=cuda)
print('REFORM complete')
return labels, costs, min_global_rotor
old_labels = [l for l in labels]
remapped_objects = [o for o in query_model]
r_est = 1.0 + 0.0*e1
assert iterations > 0, 'Must have at least 1 iteration'
for i in range(iterations):
# Reorder
reordered_list_ref = [reference_model[i] for i in labels]
# Estimate the rotor
r_est_update, exit_flag = sequential_object_rotor_estimation(reordered_list_ref, remapped_objects,
random_sequence=True, n_iterations=10,
object_type=object_type)
# Now update our running estimate
r_est = (r_est_update*r_est)
r_est = r_est.normal()
# Re map with our new rotor
remapped_objects = [apply_rotor(l, r_est).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects,
object_type=object_type, cuda=cuda)
if r_track is not None:
r_track.append(r_est)
if print_rotor:
print(r_est)
print(i)
if compare_labels(old_labels, labels):
return labels, costs, r_est
old_labels = [l for l in labels]
return labels, costs, r_est
# Re map with our new rotor
remapped_objects = [apply_rotor(l, r_est).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects,
object_type=object_type, cuda=cuda)
current_cost = np.sum(costs)
if print_rotor:
print(r_est)
print(i, current_cost, covergence_threshold)
if current_cost < min_global_cost:
min_global_cost = current_cost
min_global_rotor = +r_est
if current_cost < covergence_threshold:
return labels, costs, r_est
# Re map with our new rotor
remapped_objects = [apply_rotor(l, min_global_rotor).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects, cuda=cuda)
return labels, costs, min_global_rotor
assert iterations > 0, 'Must have at least 1 iteration'
for i in range(iterations):
# Reorder and estimate the rotor
reordered_list_a = [reference_model[i] for i in labels]
r_list, cost_array = sequential_rotor_estimation_cuda_mvs(reordered_list_a,
remapped_objects,
n_samples,
objects_per_sample,
mutation_probability=mutation_probability)
min_cost_index = np.argmin(cost_array)
min_cost = cost_array[min_cost_index]
r_est_update = r_list[min_cost_index]
r_est = (r_est_update * r_est)
r_est = r_est.normal()
# Re map with our new rotor
remapped_objects = [apply_rotor(l, r_est).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects, cuda=True)
current_cost = np.sum(costs)
print(i, covergence_threshold, current_cost, min_global_cost)
if current_cost < min_global_cost:
min_global_cost = current_cost
min_global_rotor = +r_est
if current_cost < covergence_threshold:
return labels, costs, r_est
# Re map with our new rotor
remapped_objects = [apply_rotor(l, min_global_rotor).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects, cuda=True)
return labels, costs, min_global_rotor
r_est_update = r_list[min_cost_index]
r_est = (r_est_update * r_est)
r_est = r_est.normal()
# Re map with our new rotor
remapped_objects = [apply_rotor(l, r_est).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects, cuda=True)
current_cost = np.sum(costs)
print(i, covergence_threshold, current_cost, min_global_cost)
if current_cost < min_global_cost:
min_global_cost = current_cost
min_global_rotor = +r_est
if current_cost < covergence_threshold:
return labels, costs, r_est
# Re map with our new rotor
remapped_objects = [apply_rotor(l, min_global_rotor).normal() for l in query_model]
# Get the new matching
labels, costs = assign_measurements_to_objects_matrix(reference_model, remapped_objects, cuda=True)
return labels, costs, min_global_rotor