:78 Function create_function() is deprecated [8192]

Added future compatibility to first and second network code.

Erik Spence [2017-09-22 15:39:22]
Added future compatibility to first and second network code.
Filename
code/first_network.py
code/second_network.py
diff --git a/code/first_network.py b/code/first_network.py
index 619390c..009887a 100644
--- a/code/first_network.py
+++ b/code/first_network.py
@@ -20,6 +20,7 @@ network.  Use 'build_model' to train the network.

 import numpy as np
 import numpy.random as npr
+from __future__ import print_function


 #######################################################################
@@ -179,9 +180,9 @@ def build_model(x, v, eta = 0.01, num_steps = 10000,

         # Optionally print the score.
         if (print_best) and (i % 1000 == 0):
-            print "Best by step %i: %.1f %%" % (i, best)
+            print("Best by step %i: %.1f %%" % (i, best))

-    print "Our best model gets %.1f percent correct!" % best
+    print("Our best model gets %.1f percent correct!" % best)

     # Return the best parameters
     return bestmodel
diff --git a/code/second_network.py b/code/second_network.py
index 55d1121..602369a 100644
--- a/code/second_network.py
+++ b/code/second_network.py
@@ -22,7 +22,8 @@ network.

 import numpy as np
 import numpy.random as npr
-
+from __future__ import print_function
+

 #######################################################################

@@ -267,9 +268,9 @@ def build_model(num_nodes, x, v, eta, output_dim, num_steps = 10000,

         # Optionally print the score.
         if (print_best) and (i % 1000 == 0):
-            print "Best by step %i: %.1f %%" % (i, best)
+            print("Best by step %i: %.1f %%" % (i, best))

-    print "Our best model gets %.1f percent correct!" % best
+    print("Our best model gets %.1f percent correct!" % best)

     # Return the best parameters.
     return bestmodel
ViewGit