Don't reuse the session to export

This commit is contained in:
Chris Lord 2016-11-07 18:12:41 +01:00
parent 5f58d57e62
commit 3bac760fa0

View File

@ -1395,7 +1395,7 @@
" \n",
" # Indicate optimization has concluded\n",
" print \"Optimization Finished!\"\n",
" return last_train_wer, last_validation_wer, saver"
" return last_train_wer, last_validation_wer"
]
},
{
@ -1425,7 +1425,7 @@
" time_started = datetime.datetime.utcnow()\n",
" \n",
" # Train the network\n",
" last_train_wer, last_validation_wer, saver = train(session, data_sets)\n",
" last_train_wer, last_validation_wer = train(session, data_sets)\n",
" \n",
" # Take final time for time measurement\n",
" time_finished = datetime.datetime.utcnow()\n",
@ -1475,9 +1475,14 @@
"# Don't export a model if no export directory has been set\n",
"if export_dir:\n",
" with tf.device('/cpu:0'):\n",
" session = tf.Session(config=tf.ConfigProto(allow_soft_placement=True, log_device_placement=True))\n",
" saver = tf.train.Saver(tf.all_variables())\n",
" model_exporter = exporter.Exporter(saver)\n",
"\n",
" # Run inference\n",
" # Replace the dropout placeholder with a constant\n",
" dropout_rate_placeholder = tf.constant(0.0)\n",
"\n",
" # Input tensor will be of shape [batch_size, n_steps, n_input + 2*n_input*n_context]\n",
" input_tensor = tf.placeholder(tf.float32, [None, None, n_input + 2*n_input*n_context])\n",
"\n",
@ -1510,8 +1515,7 @@
" model_exporter.init(session.graph.as_graph_def(),\n",
" named_graph_signatures = {\n",
" 'inputs': exporter.generic_signature(\n",
" { 'input': input_tensor,\n",
" 'dropout_rate': dropout_rate_placeholder }),\n",
" { 'input': input_tensor }),\n",
" 'outputs': exporter.generic_signature(\n",
" { 'outputs': decoded})})\n",
" model_exporter.export(export_dir, tf.constant(export_version), session)\n",