Tensorflow NotFoundError:容器localhost不存在。(找不到资源:localhost/embedding\u 1/embeddings)
我有一个非常简单的代码,我想添加嵌入,但我得到了错误。我想看看嵌入输出 我的代码:Tensorflow NotFoundError:容器localhost不存在。(找不到资源:localhost/embedding\u 1/embeddings),tensorflow,embedding,Tensorflow,Embedding,我有一个非常简单的代码,我想添加嵌入,但我得到了错误。我想看看嵌入输出 我的代码: 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}
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})
错误:
in_do_call(self、fn、*args)
1364尝试:
->1365返回fn(*args)
1366错误除外。操作错误为e:
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
in_run_fn(feed_dict、fetch_list、target_list、options、run_元数据)
1349返回self.\u调用\u tf\u sessionrun(选项、提要、获取列表、,
->1350目标\u列表,运行\u元数据)
1351年
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在调用会话运行中(self、options、feed、dict、fetch、list、,
目标\u列表,运行\u元数据)
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、handle、fetches、feed\u dict、options、run\u元数据)
1178如果final_获取或final_目标或(句柄和馈送dict_张量):
1179 results=self.\u do\u run(句柄、最终目标、最终获取、,
->1180提要(输入张量、选项、运行元数据)
1181其他:
1182结果=[]
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
在运行中(self、handle、target、fetch、feed、dict、options、,
运行(元数据)
1357如果句柄为“无”:
1358返回self.\u do\u call(\u run\u fn,feed,fetches,targets,options,
->1359运行单元(元数据)
1360其他:
1361返回self.\u do\u调用(\u prun\u fn、句柄、提要、获取)
in_do_call(self、fn、*args)
1382'\n会话配置图选项。重写选项。'
1383“禁用元优化器=真”)
->1384提升类型(e)(节点定义、操作、消息)
1385
1386定义扩展图(自):
]]
询问解决方案您似乎缺少对创建模型时使用的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)
相关问题:
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
~/miniconda2/envs/py3/lib/python3.7/site-packages/tensorflow_core/python/client/session.py
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)
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)