Skip to content

Commit a8b6b4f

Browse files
author
yangyaming
committed
Change assert to exception raising.
1 parent 49e5e51 commit a8b6b4f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

deep_speech_2/train.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@
8181
help="Vocabulary filepath. (default: %(default)s)")
8282
parser.add_argument(
8383
"--init_model_path",
84-
default='models/params.tar.gz',
84+
default=None,
8585
type=str,
86-
help="Model path for initialization. (default: %(default)s)")
86+
help="If set None, the training will start from scratch. "
87+
"Otherwise, the training will resume from the existing model of this path. (default: %(default)s)"
88+
)
8789
args = parser.parse_args()
8890

8991

@@ -124,7 +126,8 @@ def train():
124126
if args.init_model_path is None:
125127
parameters = paddle.parameters.create(cost)
126128
else:
127-
assert os.path.isfile(args.init_model_path), "Invalid model."
129+
if not os.path.isfile(args.init_model_path):
130+
raise IOError("Invalid model!")
128131
parameters = paddle.parameters.Parameters.from_tar(
129132
gzip.open(args.init_model_path))
130133
optimizer = paddle.optimizer.Adam(

0 commit comments

Comments
 (0)