【问题标题】:Combine graphs in tensorflow在张量流中组合图
【发布时间】:2018-04-03 17:02:10
【问题描述】:

我不知道如何处理这个问题。 我有一个图,g1,用于提取特征。

class FeatureExtractor():
    self.g1
    ...
    def _build_model():
        ...
    def compute_features(new_in):
        out = self.session.run(self.compute_out(), feed_dict = {self.in_: new_in})

我想在另一个图 g2 中使用这个图,如下所示:

class LSTM():
    def __init__(feature_extractor):
        self.fe = feature_extractor
    def _build_model():
        ....
        signal = tf.map_fn(self.fe.compute_features, signal)

但我收到此错误。

TypeError: The value of a feed cannot be a tf.Tensor object. Acceptable feed values include Python scalars, strings, lists, numpy ndarrays, or TensorHandles.

因为 compute_features 需要 np.array 或类似的东西将其提供给 g1。

有什么办法可以做到吗?

【问题讨论】:

    标签: tensorflow typeerror tensor


    【解决方案1】:

    张量是符号对象,所以不能在 feed_dict 中提供,给它作为 sess.run(tensor_object)

    最好在这里讨论:-

    https://github.com/tensorflow/tensorflow/issues/3389

    【讨论】:

    • 感谢您的回答!我也尝试过,但不幸的是我无法在图中运行会话,因为该图中有一些张量需要初始化
    猜你喜欢
    • 1970-01-01
    • 2017-09-17
    • 1970-01-01
    • 2021-04-26
    • 1970-01-01
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 2017-05-11
    相关资源
    最近更新 更多