NotFoundError:容器本地主机不存在。 (找不到资源:localhost/embedding_1/embeddings)
Posted
技术标签:
【中文标题】NotFoundError:容器本地主机不存在。 (找不到资源:localhost/embedding_1/embeddings)【英文标题】:NotFoundError: Container localhost does not exist. (Could not find resource: localhost/embedding_1/embeddings) 【发布时间】:2020-08-25 03:50:41 【问题描述】:我有一个非常简单的代码,我想在其中添加嵌入,但出现错误。我想查看嵌入输出。
我的代码:
input_question_ = Input((query_maxlen,))
embedded_question = Embedding(vocab_size, embedding_dim)(input_question_)
sess = tf.Session()
sess.run(embedded_question, feed_dict= input_question_: queries_train)
错误:
--------------------------------------------------------------------------- NotFoundError Traceback (most recent call last) ~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在 _do_call(self, fn, *args) 1364 尝试: -> 1365 返回 fn(*args) 1366 除了errors.OpError as e:
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在 _run_fn(feed_dict, fetch_list, target_list, options, run_metadata) 第1349章 -> 1350 目标列表,运行元数据) 第1351章
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在 _call_tf_sessionrun(self, options, feed_dict, fetch_list, 目标列表,运行元数据) 第1442章 -> 1443 运行元数据) 第1444章
NotFoundError: Container localhost does not exist. (Could not find resource: localhost/embedding_1/embeddings) [[node embedding_1/embedding_lookup]] During handling of the above exception, another exception occurred: NotFoundError Traceback (most recent call last) <ipython-input-95-bf218d6ed295> in <module> 39 sess = tf.Session() 40 ---> 41 sess.run(embedded_question, feed_dict= input_question_: queries_train) ~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在运行中(self、fetches、feed_dict、options、run_metadata) 954尝试: 第955章 --> 956 run_metadata_ptr) 957 如果运行元数据: 958 proto_data = tf_session.TF_GetBuffer(运行元数据ptr)
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
in _run(self, handle, fetches, feed_dict, options, run_metadata) 1178 如果 final_fetches 或 final_targets 或(句柄和 feed_dict_tensor): 1179 结果 = self._do_run(句柄,final_targets,final_fetches, -> 1180 feed_dict_tensor,选项,run_metadata) 1181 其他: 1182 个结果 = []
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在 _do_run(self, handle, target_list, fetch_list, feed_dict, options, 运行元数据) 1357 如果句柄为无: 第1358章 -> 1359 运行元数据) 1360 其他: 第1361章
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在 _do_call(self, fn, *args) 第1382章 第1383章 -> 1384 提升类型(e)(node_def,op,消息) 1385 第1386章
NotFoundError: Container localhost does not exist. (Could not find resource: localhost/embedding_1/embeddings) [[node embedding_1/embedding_lookup (defined at /home/mzaman/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/framework/ops.py:1748)
]]
寻求解决方案
【问题讨论】:
【参考方案1】:您似乎缺少对创建模型的 Tensorflow 会话的引用。试试:
import numpy as np
import tensorflow as tf
query_maxlen = 100
vocab_size = 500
embedding_dim = 32
input_question = tf.keras.layers.Input((query_maxlen,))
embedded_question = tf.keras.layers.Embedding(vocab_size, embedding_dim)(input_question)
sess = tf.keras.backend.get_session()
output = sess.run(
embedded_question, feed_dict=input_question: np.ones((1, query_maxlen))
)
assert (1, 100, 32) == output.shape
print(output)
相关问题: Container localhost does not exist error when using Keras + Flask Blueprints
【讨论】:
以上是关于NotFoundError:容器本地主机不存在。 (找不到资源:localhost/embedding_1/embeddings)的主要内容,如果未能解决你的问题,请参考以下文章