|
|
@ -81,9 +81,11 @@ parser.add_argument(
|
|
|
|
help="Vocabulary filepath. (default: %(default)s)")
|
|
|
|
help="Vocabulary filepath. (default: %(default)s)")
|
|
|
|
parser.add_argument(
|
|
|
|
parser.add_argument(
|
|
|
|
"--init_model_path",
|
|
|
|
"--init_model_path",
|
|
|
|
default='models/params.tar.gz',
|
|
|
|
default=None,
|
|
|
|
type=str,
|
|
|
|
type=str,
|
|
|
|
help="Model path for initialization. (default: %(default)s)")
|
|
|
|
help="If set None, the training will start from scratch. "
|
|
|
|
|
|
|
|
"Otherwise, the training will resume from "
|
|
|
|
|
|
|
|
"the existing model of this path. (default: %(default)s)")
|
|
|
|
args = parser.parse_args()
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -124,7 +126,8 @@ def train():
|
|
|
|
if args.init_model_path is None:
|
|
|
|
if args.init_model_path is None:
|
|
|
|
parameters = paddle.parameters.create(cost)
|
|
|
|
parameters = paddle.parameters.create(cost)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
assert os.path.isfile(args.init_model_path), "Invalid model."
|
|
|
|
if not os.path.isfile(args.init_model_path):
|
|
|
|
|
|
|
|
raise IOError("Invalid model!")
|
|
|
|
parameters = paddle.parameters.Parameters.from_tar(
|
|
|
|
parameters = paddle.parameters.Parameters.from_tar(
|
|
|
|
gzip.open(args.init_model_path))
|
|
|
|
gzip.open(args.init_model_path))
|
|
|
|
optimizer = paddle.optimizer.Adam(
|
|
|
|
optimizer = paddle.optimizer.Adam(
|
|
|
|