提交 b872d21a 编写于 作者: J JiabinYang

insert header files and change the print() to match python3 style

上级 5513a343
...@@ -204,6 +204,7 @@ from functools import partial ...@@ -204,6 +204,7 @@ from functools import partial
import math import math
import os import os
import sys import sys
from __future__ import print_function
``` ```
然后,定义参数: 然后,定义参数:
...@@ -311,7 +312,7 @@ def train(use_cuda, train_program, params_dirname): ...@@ -311,7 +312,7 @@ def train(use_cuda, train_program, params_dirname):
feed_order=['firstw', 'secondw', 'thirdw', 'fourthw', 'nextw']) feed_order=['firstw', 'secondw', 'thirdw', 'fourthw', 'nextw'])
avg_cost = outs[0] avg_cost = outs[0]
print "Step %d: Average Cost %f" % (event.step, avg_cost) print("Step %d: Average Cost %f" % (event.step, avg_cost))
# If average cost is lower than 5.8, we consider the model good enough to stop. # If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should # Note 5.8 is a relatively high value. In order to get a better model, one should
......
...@@ -222,6 +222,7 @@ from functools import partial ...@@ -222,6 +222,7 @@ from functools import partial
import math import math
import os import os
import sys import sys
from __future__ import print_function
``` ```
- Configure parameters and build word dictionary. - Configure parameters and build word dictionary.
...@@ -328,7 +329,7 @@ def train(use_cuda, train_program, params_dirname): ...@@ -328,7 +329,7 @@ def train(use_cuda, train_program, params_dirname):
# We output cost every 10 steps. # We output cost every 10 steps.
if event.step % 10 == 0: if event.step % 10 == 0:
print "Step %d: Average Cost %f" % (event.step, avg_cost) print("Step %d: Average Cost %f" % (event.step, avg_cost)
# If average cost is lower than 5.8, we consider the model good enough to stop. # If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should # Note 5.8 is a relatively high value. In order to get a better model, one should
......
...@@ -246,6 +246,7 @@ from functools import partial ...@@ -246,6 +246,7 @@ from functools import partial
import math import math
import os import os
import sys import sys
from __future__ import print_function
``` ```
然后,定义参数: 然后,定义参数:
...@@ -353,7 +354,7 @@ def train(use_cuda, train_program, params_dirname): ...@@ -353,7 +354,7 @@ def train(use_cuda, train_program, params_dirname):
feed_order=['firstw', 'secondw', 'thirdw', 'fourthw', 'nextw']) feed_order=['firstw', 'secondw', 'thirdw', 'fourthw', 'nextw'])
avg_cost = outs[0] avg_cost = outs[0]
print "Step %d: Average Cost %f" % (event.step, avg_cost) print("Step %d: Average Cost %f" % (event.step, avg_cost))
# If average cost is lower than 5.8, we consider the model good enough to stop. # If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should # Note 5.8 is a relatively high value. In order to get a better model, one should
......
...@@ -264,6 +264,7 @@ from functools import partial ...@@ -264,6 +264,7 @@ from functools import partial
import math import math
import os import os
import sys import sys
from __future__ import print_function
``` ```
- Configure parameters and build word dictionary. - Configure parameters and build word dictionary.
...@@ -370,7 +371,7 @@ def train(use_cuda, train_program, params_dirname): ...@@ -370,7 +371,7 @@ def train(use_cuda, train_program, params_dirname):
# We output cost every 10 steps. # We output cost every 10 steps.
if event.step % 10 == 0: if event.step % 10 == 0:
print "Step %d: Average Cost %f" % (event.step, avg_cost) print("Step %d: Average Cost %f" % (event.step, avg_cost))
# If average cost is lower than 5.8, we consider the model good enough to stop. # If average cost is lower than 5.8, we consider the model good enough to stop.
# Note 5.8 is a relatively high value. In order to get a better model, one should # Note 5.8 is a relatively high value. In order to get a better model, one should
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册