导入tensorflow.contrib.slim时如何解决UnicodeDecodeError

问题描述 投票:1回答:1

导入tensorflow.contrib.slim时出现此问题

import tensorflow.contrib.slim as slim

回溯是:

Traceback (most recent call last):
  File "finetune-sintel.py", line 22, in <module>
    from model_pwcnet import ModelPWCNet, _DEFAULT_PWCNET_FINETUNE_OPTIONS
  File "/home/sxl/ext4-2T-3/code/tfoptflow-master/tfoptflow/model_pwcnet.py", line 21, in <module>
    from model_base import ModelBase
  File "/home/sxl/ext4-2T-3/code/tfoptflow-master/tfoptflow/model_base.py", line 15, in <module>
    import tensorflow.contrib.slim as slim
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/__init__.py", line 22, in <module>
    from tensorflow.contrib import bayesflow
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/__init__.py", line 24, in <module>
    from tensorflow.contrib.bayesflow.python.ops import entropy
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/python/ops/entropy.py", line 23, in <module>
    from tensorflow.contrib.bayesflow.python.ops.entropy_impl import *
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/python/ops/entropy_impl.py", line 30, in <module>
    from tensorflow.contrib.bayesflow.python.ops import variational_inference
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/python/ops/variational_inference.py", line 26, in <module>
    from tensorflow.contrib.bayesflow.python.ops.variational_inference_impl import *
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/python/ops/variational_inference_impl.py", line 29, in <module>
    from tensorflow.contrib.bayesflow.python.ops import stochastic_graph_impl as sg
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/python/ops/stochastic_graph_impl.py", line 28, in <module>
    from tensorflow.contrib.bayesflow.python.ops import stochastic_tensor_impl
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/bayesflow/python/ops/stochastic_tensor_impl.py", line 51, in <module>
    from tensorflow.contrib.distributions.python.ops import distribution
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/distributions/__init__.py", line 91, in <module>
    from tensorflow.contrib.distributions.python.ops.bernoulli import *
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/distributions/python/ops/bernoulli.py", line 21, in <module>
    from tensorflow.contrib.distributions.python.ops import distribution
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/distributions/python/ops/distribution.py", line 29, in <module>
    from tensorflow.contrib import framework as contrib_framework
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/framework/__init__.py", line 81, in <module>
    from tensorflow.contrib.framework.python.ops import *
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/__init__.py", line 26, in <module>
    from tensorflow.contrib.framework.python.ops.variables import *
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/variables.py", line 26, in <module>
    from tensorflow.contrib.framework.python.ops import gen_variable_ops
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/contrib/framework/python/ops/gen_variable_ops.py", line 40, in <module>
    _ops.RegisterShape("ZeroInitializer")(None)
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1697, in __call__
    self._op_type)
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/site-packages/tensorflow/python/framework/registry.py", line 67, in register
    stack = traceback.extract_stack()
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/traceback.py", line 211, in extract_stack
    stack = StackSummary.extract(walk_stack(f), limit=limit)
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/traceback.py", line 364, in extract
    f.line
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/traceback.py", line 286, in line
    self._line = linecache.getline(self.filename, self.lineno).strip()
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/linecache.py", line 16, in getline
    lines = getlines(filename, module_globals)
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/linecache.py", line 47, in getlines
    return updatecache(filename, module_globals)
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/linecache.py", line 137, in updatecache
    lines = fp.readlines()
  File "/home/sxl/anaconda3/envs/tfpy36/lib/python3.6/codecs.py", line 321, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcf in position 4307: invalid continuation byte
python tensorflow python-unicode
1个回答
0
投票
Tensorflow 1Tensorflow 2提供解决方案。
© www.soinside.com 2019 - 2024. All rights reserved.