首页 > 解决方案 > 通过 python 在 MATLAB 中创建 tensorflow 会话

问题描述

我正在尝试通过 MATLAB 使用 Tensorflow,我首先创建了一个脚本“mymod”,如下所示:

# mymod.py
import tensorflow as tf
def run():
    with tf.Session() as sess:
        a = 1
    return a

在 MATLAB 命令窗口中运行脚本函数“run()”:

py.mymod.run()

然后我得到了这个错误:

Error using errors_impl>__exit__ (line 473)
Python Error: NotFoundError: No session factory registered for the given     
session options: {target: "" config:} Registered factories are {}.

Error in session>__init__ (line 622)
      self._session = tf_session.TF_NewDeprecatedSession(opts, status)

Error in session>__init__ (line 1482)
    super(Session, self).__init__(target, graph, config=config)

Error in mymod>run (line 4)
    with tf.Session() as sess:

如何解决这个问题?

标签: pythonmatlabtensorflow

解决方案


推荐阅读