-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnicodeDecodeError in ch14_part2.ipynb #162
Comments
Hard to say, but my best guess is that the dataframe was maybe not loaded correctly. Could you check and show a screenshot of how the data frame looks like? E.g., maybe screenshot the output from df.tail() or df.head() |
Thank you for your response. |
Hm, so strange! I mean, it's nice that the dataframe looks ok, but this makes it harder to debug. Instead of regressor = tf.estimator.DNNRegressor(
feature_columns=all_feature_columns,
hidden_units=[32, 10],
model_dir='models/autompg-dnnregressor/') can you change it to regressor = tf.estimator.DNNRegressor(
feature_columns=all_feature_columns,
hidden_units=[32, 10],
model_dir="regressor") |
I tried the code as you told, and it caused no errors.
It was my easy mistake. Now I can proceed to read the book. |
Glad to hear it worked! |
I met an error executing following code.
I would like to know how to solve the problem.
In[15]:
###########################
EPOCHS = 1000
BATCH_SIZE = 8
total_steps = EPOCHS * int(np.ceil(len(df_train) / BATCH_SIZE))
print('Training Steps: ', total_steps)
regressor.train(input_fn = lambda: train_input_fn(df_train_norm, batch_size = BATCH_SIZE),
steps = total_steps)
result:
###########################
Training Steps: 40000
WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\training_util.py:396: Variable.initialized_value (from tensorflow.python.ops.variables) is deprecated and will be removed in a future version.
Instructions for updating:
Use Variable.read_value. Variables in 2.X are initialized automatically both in eager and graph (inside tf.defun) contexts.
INFO:tensorflow:Calling model_fn.
WARNING:tensorflow:From C:\ProgramData\Anaconda3\lib\site-packages\keras\optimizers\optimizer_v2\adagrad.py:90: calling Constant.init (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.
Instructions for updating:
Call initializer instance with the dtype argument instead of passing it to the constructor
INFO:tensorflow:Done calling model_fn.
INFO:tensorflow:Create CheckpointSaverHook.
INFO:tensorflow:Graph was finalized.
INFO:tensorflow:Running local_init_op.
INFO:tensorflow:Done running local_init_op.
INFO:tensorflow:Calling checkpoint listeners before saving checkpoint 0...
INFO:tensorflow:Saving checkpoints for 0 into models/autompg-dnnregressor/model.ckpt.
UnicodeDecodeError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_19944/1793407232.py in
6 print('Training Steps: ', total_steps)
7
----> 8 regressor.train(input_fn = lambda: train_input_fn(df_train_norm, batch_size = BATCH_SIZE),
9 steps = total_steps)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py in train(self, input_fn, hooks, steps, max_steps, saving_listeners)
358
359 saving_listeners = _check_listeners_type(saving_listeners)
--> 360 loss = self._train_model(input_fn, hooks, saving_listeners)
361 logging.info('Loss for final step: %s.', loss)
362 return self
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py in _train_model(self, input_fn, hooks, saving_listeners)
1184 return self._train_model_distributed(input_fn, hooks, saving_listeners)
1185 else:
-> 1186 return self._train_model_default(input_fn, hooks, saving_listeners)
1187
1188 def _train_model_default(self, input_fn, hooks, saving_listeners):
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py in _train_model_default(self, input_fn, hooks, saving_listeners)
1215 self.config)
1216 global_step_tensor = tf.compat.v1.train.get_global_step(g)
-> 1217 return self._train_with_estimator_spec(estimator_spec, worker_hooks,
1218 hooks, global_step_tensor,
1219 saving_listeners)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow_estimator\python\estimator\estimator.py in _train_with_estimator_spec(self, estimator_spec, worker_hooks, hooks, global_step_tensor, saving_listeners)
1510 output_dir=self._config.model_dir))
1511
-> 1512 with training.MonitoredTrainingSession(
1513 master=self._config.master,
1514 is_chief=self._config.is_chief,
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\monitored_session.py in MonitoredTrainingSession(master, is_chief, checkpoint_dir, scaffold, hooks, chief_only_hooks, save_checkpoint_secs, save_summaries_steps, save_summaries_secs, config, stop_grace_period_secs, log_step_count_steps, max_wait_secs, save_checkpoint_steps, summary_dir, save_graph_def)
607 if hooks:
608 all_hooks.extend(hooks)
--> 609 return MonitoredSession(
610 session_creator=session_creator,
611 hooks=all_hooks,
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\monitored_session.py in init(self, session_creator, hooks, stop_grace_period_secs)
1052 hooks=None,
1053 stop_grace_period_secs=120):
-> 1054 super(MonitoredSession, self).init(
1055 session_creator,
1056 hooks,
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\monitored_session.py in init(self, session_creator, hooks, should_recover, stop_grace_period_secs)
755 stop_grace_period_secs=stop_grace_period_secs)
756 if should_recover:
--> 757 self._sess = _RecoverableSession(self._coordinated_creator)
758 else:
759 self._sess = self._coordinated_creator.create_session()
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\monitored_session.py in init(self, sess_creator)
1261 """
1262 self._sess_creator = sess_creator
-> 1263 _WrappedSession.init(self, self._create_session())
1264
1265 def _create_session(self):
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\monitored_session.py in _create_session(self)
1266 while True:
1267 try:
-> 1268 return self._sess_creator.create_session()
1269 except _PREEMPTION_ERRORS as e:
1270 logging.info(
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\monitored_session.py in create_session(self)
915 # Inform the hooks that a new session has been created.
916 for hook in self._hooks:
--> 917 hook.after_create_session(self.tf_sess, self.coord)
918 return _CoordinatedSession(
919 _HookedSession(self.tf_sess, self._hooks), self.coord,
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\basic_session_run_hooks.py in after_create_session(self, session, coord)
600 self._summary_writer.add_meta_graph(meta_graph_def)
601 # The checkpoint saved here is the state at step "global_step".
--> 602 self._save(session, global_step)
603 self._timer.update_last_triggered_step(global_step)
604
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\basic_session_run_hooks.py in _save(self, session, step)
632
633 logging.info("Saving checkpoints for %d into %s.", step, self._save_path)
--> 634 self._get_saver().save(session, self._save_path, global_step=step,
635 write_meta_graph=self._save_graph_def)
636 self._summary_writer.add_session_log(
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\training\saver.py in save(self, sess, save_path, global_step, latest_filename, meta_graph_suffix, write_meta_graph, write_state, strip_default_attrs, save_debug_info)
1282 model_checkpoint_path = self.saver_def.save_tensor_name
1283 else:
-> 1284 model_checkpoint_path = sess.run(
1285 self.saver_def.save_tensor_name,
1286 {self.saver_def.filename_tensor_name: checkpoint_file})
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in run(self, fetches, feed_dict, options, run_metadata)
966
967 try:
--> 968 result = self._run(None, fetches, feed_dict, options_ptr,
969 run_metadata_ptr)
970 if run_metadata:
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
1189 # or if the call is a partial run that specifies feeds.
1190 if final_fetches or final_targets or (handle and feed_dict_tensor):
-> 1191 results = self._do_run(handle, final_targets, final_fetches,
1192 feed_dict_tensor, options, run_metadata)
1193 else:
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_run(self, handle, target_list, fetch_list, feed_dict, options, run_metadata)
1369
1370 if handle is None:
-> 1371 return self._do_call(_run_fn, feeds, fetches, targets, options,
1372 run_metadata)
1373 else:
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _do_call(self, fn, *args)
1376 def _do_call(self, fn, *args):
1377 try:
-> 1378 return fn(*args)
1379 except errors.OpError as e:
1380 message = compat.as_text(e.message)
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _run_fn(feed_dict, fetch_list, target_list, options, run_metadata)
1359 # Ensure any changes to the graph are reflected in the runtime.
1360 self._extend_graph()
-> 1361 return self._call_tf_sessionrun(options, feed_dict, fetch_list,
1362 target_list, run_metadata)
1363
C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\client\session.py in _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list, run_metadata)
1452 def _call_tf_sessionrun(self, options, feed_dict, fetch_list, target_list,
1453 run_metadata):
-> 1454 return tf_session.TF_SessionRun_wrapper(self._session, options, feed_dict,
1455 fetch_list, target_list,
1456 run_metadata)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8e in position 155: invalid start byte
The text was updated successfully, but these errors were encountered: