Skip to content
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

KeyError: "The name 'FID_Inception_Net/pool_3:0' refers to a Tensor which does not exist. The operation, 'FID_Inception_Net/pool_3', does not exist in the graph." #42

Open
mzc0119 opened this issue Feb 3, 2021 · 3 comments

Comments

@mzc0119
Copy link

mzc0119 commented Feb 3, 2021

Hello, thanks for your wonderful work. I run in colab and I have met an error recently. but I don't know how to fix it.
Here is the whole message:

create inception graph.. ok
calculte FID stats..

KeyError Traceback (most recent call last)
in ()
6 with tf.compat.v1.Session() as Sess:
7 Sess.run(tf.compat.v1.global_variables_initializer())
----> 8 mu_gen, sigma_gen = fid.calculate_activation_statistics(images, Sess, batch_size=100)
9
10 fid.fid_value = calculate_frechet_distance(mu_gen, sigma_gen, mu_real, sigma_real)

5 frames
/content/TTUR/fid.py in calculate_activation_statistics(images, sess, batch_size, verbose)
178 the incption model.
179 """
--> 180 act = get_activations(images, sess, batch_size, verbose)
181 mu = np.mean(act, axis=0)
182 sigma = np.cov(act, rowvar=False)

/content/TTUR/fid.py in get_activations(images, sess, batch_size, verbose)
81 activations of the given tensor when feeding inception with the query tensor.
82 """
---> 83 inception_layer = _get_inception_layer(sess)
84 n_images = images.shape[0]
85 if batch_size > n_images:

/content/TTUR/fid.py in _get_inception_layer(sess)
47 """Prepares inception net for batched usage and returns pool_3 layer. """
48 layername = 'FID_Inception_Net/pool_3:0'
---> 49 pool3 = sess.graph.get_tensor_by_name(layername)
50 ops = pool3.graph.get_operations()
51 for op_idx, op in enumerate(ops):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in get_tensor_by_name(self, name)
3900 raise TypeError("Tensor names are strings (or similar), not %s." %
3901 type(name).name)
-> 3902 return self.as_graph_element(name, allow_tensor=True, allow_operation=False)
3903
3904 def _get_tensor_by_tf_output(self, tf_output):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in as_graph_element(self, obj, allow_tensor, allow_operation)
3724
3725 with self._lock:
-> 3726 return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
3727
3728 def _as_graph_element_locked(self, obj, allow_tensor, allow_operation):

/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py in _as_graph_element_locked(self, obj, allow_tensor, allow_operation)
3766 raise KeyError("The name %s refers to a Tensor which does not "
3767 "exist. The operation, %s, does not exist in the "
-> 3768 "graph." % (repr(name), repr(op_name)))
3769 try:
3770 return op.outputs[out_n]

KeyError: "The name 'FID_Inception_Net/pool_3:0' refers to a Tensor which does not exist. The operation, 'FID_Inception_Net/pool_3', does not exist in the graph."

@soren5
Copy link

soren5 commented Feb 10, 2021

I am having this same issue. Worked file on my Windows10 machine but when trying to use it in linux I got this same error

@Tardiser
Copy link

I've fixed the issue by deleting "FID_Inception_Net" from create_inception_graph, _get_inception_layer, and get_activations. The problem is probably due to the Colab's different path.

@ps-raghotham-rao
Copy link

I've fixed the issue by deleting "FID_Inception_Net" from create_inception_graph, _get_inception_layer, and get_activations. The problem is probably due to the Colab's different path.

Thanks a lot!
For people noob like me. Just use google's tf upgrade tool. Then whereever "FID_Inception_Net" is there. Change it to "FID_Inception_Net". If "FID_Inception_Net/something" then "something".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants