在tensorflow中组合图形

时间:2018-04-03 17:02:10

标签: tensorflow typeerror tensor

我不知道如何处理这个问题。 我有一个图表,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。

我有什么方法可以做到这一点吗?

1 个答案:

答案 0 :(得分:0)

张量是符号对象,因此无法在feed_dict中提供,请将其命名为sess.run(tensor_object)

这里有更好的讨论: -

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

相关问题