1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
Index: enki-aseba/tools/compute_ir_sensors_params.py
===================================================================
--- enki-aseba.orig/tools/compute_ir_sensors_params.py
+++ enki-aseba/tools/compute_ir_sensors_params.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import argparse
import numpy as np
from scipy.optimize import fmin
@@ -15,7 +15,7 @@ def main():
y = map(float, args.activations.split(','))
if len(x) != len(y):
raise RuntimeError('distances array size %d is different than activations array size %d' % (len(x), len(y)))
- print x,y
+ print (x,y)
# function to optimise
def F(v):
@@ -29,24 +29,24 @@ def main():
denom = math.copysign(1e-30, denom)
err = (yi - a / denom)
error += err * err
- #print error
+ #print (error)
return error
# run optimisation
#res, Jmin = anneal(F, [10.,10.,10.], lower=-1e5, upper=1e5, maxiter=100000)
- #print res, Jmin
+ #print (res, Jmin)
best_val = 1e100
best_x = None
for i in range(1000):
init_x = np.random.normal(scale=1000,size=3)
- #print init_x
+ #print (init_x)
res = fmin(F, init_x)
res_val = F(res)
if res_val < best_val:
- print 'new best val ', best_val
+ print ('new best val ', best_val)
best_val = res_val
best_x = res
- print best_x, best_val
+ print (best_x, best_val)
if __name__ == '__main__':
- main()
\ No newline at end of file
+ main()
Index: enki-aseba/tools/compute_ir_sensors_ray_weights.py
===================================================================
--- enki-aseba.orig/tools/compute_ir_sensors_ray_weights.py
+++ enki-aseba/tools/compute_ir_sensors_ray_weights.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import argparse
import numpy as np
import math
@@ -22,7 +22,7 @@ def main():
y = map(float, args.distances.split(','))
if len(x) != len(y):
raise RuntimeError('angle array size %d is different than distance array size %d' % (len(x), len(y)))
- print p,x,y
+ print (p,x,y)
# activation function
def F(x):
@@ -51,22 +51,22 @@ def main():
if verbose:
print('Angle: %f, dist: %f, F(dist): %f, F_dsim: %f' % (xi, yi, F(yi), F_dsim(xi)))
error += err * err
- #print error
+ #print (error)
return error
best_val = 1e100
best_x = None
for i in range(100):
init_x = [max(np.abs(x))/3., abs(np.random.normal(scale=1)), abs(np.random.normal(scale=1))]
- print init_x
+ print (init_x)
res = fmin(E, init_x)
res_val = E(res)
if res_val < best_val:
- print 'new best val ', best_val
+ print ('new best val ', best_val)
best_val = res_val
best_x = res
- print best_x, best_val
+ print (best_x, best_val)
E(best_x, True)
if __name__ == '__main__':
- main()
\ No newline at end of file
+ main()
|