IndentationError: unexpected indent

Asked 2 years ago, Updated 2 years ago, 41 views

 # Finally, it loads mapping from integer node ID to human-readable characters.
    node_id_to_name = {}
    for key, val in node_id_to_uid.items():
      if val not in uid_to_human:
        tf.logging.fatal('Failed to locate: %s', val)
      name = uid_to_human[val]
      node_id_to_name[key] = name

    return node_id_to_name

  def id_to_string(self, node_id):
    if node_id not in self.node_lookup:
      return ''
    return self.node_lookup[node_id]


def create_graph():
    """Generates a graph from a saved GraphDef file and returns a saved value."""
  # # Creates graph from saved graph_def.pb.
  with tf.gfile.FastGFile(os.path.join(
      FLAGS.model_dir, 'classify_image_graph_def.pb'), 'rb') as f:
    graph_def = tf.GraphDef()
    graph_def.ParseFromString(f.read())
    _ = tf.import_graph_def(graph_def, name='')

File "", line 11 def id_to_string(self, node_id): ^ IndentationError: unexpected indent There is an error, but I don't know where the spacing went wrong. Oh! For your information, this is a partial code for the Inception-v3 model example.

python tensorflow

2022-09-22 16:55

1 Answers

You can't mix tab and space.

And even if you look at it roughly, the indent is 4 spaces and 2 spaces.

Python is an indented language.

Set the tabs to 4 spaces and work.

Pythonide (wingide, pycharm, pyscripter, etc.), which is used a lot, has a source format function that makes it easy to solve.


2022-09-22 16:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.