Esempio n. 1
0
positions = np.random.randn(len(ids), dimensions)

print("Running OpenCL")

cl_start = time.time()
results = euclidean_embedder_cl.embed(ids, distance_list, positions,
                                      rate=.0005, iterations=1000)
cl_end = time.time()

with open('ranks_cl.csv', 'w') as csvfile:
    writer = csv.writer(csvfile)
    writer.writerows(results)


print("Running Python")


py_start = time.time()
positions_dict = dict(zip(ids, list(positions)))
result_dict = euclidean_embedder.embed(positions_dict, distance_list,
                                       rate=.0005, iterations=1000)
py_end = time.time()

with open('ranks_py.csv', 'w') as csvfile:
    writer = csv.writer(csvfile)
    for team, position in result_dict.items():
        writer.writerow([team] + list(position))

print("OpenCL run time: " + str(cl_end - cl_start))
print("Python run time: " + str(py_end - py_start))
Esempio n. 2
0
dimensions = 1

# Here I generate random initial positions, but choosing better
# initial positions should result in quicker or better results
positions = np.random.randn(len(ids), dimensions)

print("Running OpenCL")

cl_start = time.time()
results = euclidean_embedder_cl.embed(ids, distance_list, positions,
                                      rate=.0005, iterations=10000)
cl_end = time.time()

with open('ranks_cl.csv', 'w') as csvfile:
    writer = csv.writer(csvfile)
    writer.writerows(results)


print("Running Python")
py_start = time.time()
results = euclidean_embedder.embed(ids, distance_list, positions,
                                   rate=.0005, iterations=100)
py_end = time.time()

with open('ranks_py.csv', 'w') as csvfile:
    writer = csv.writer(csvfile)
    writer.writerows(results)

print("OpenCL run time: " + str(cl_end - cl_start))
print("Python run time: " + str(py_end - py_start))