【问题标题】:Failed copying input tensor from /job:localhost/replica:0/task:0/device:CPU:0 to /job:localhost/replica:0/task:0/device:GPU:0 in order to run Cast将输入张量从 /job:localhost/replica:0/task:0/device:CPU:0 复制到 /job:localhost/replica:0/task:0/device:GPU:0 以运行 Cast 失败
【发布时间】:2021-04-18 06:52:20
【问题描述】:

我有一个自动编码器类,我尝试将具有形状 (2933314, 600) 的 normal_test_data 提供给编码器。我从 /job:localhost/replica:0/task:0/device:CPU:0 到 /job:localhost/replica:0/task:0/device:GPU:0 复制输入张量失败,以便运行 Cast : Dst 张量未初始化。 [Op:Cast] 内存不足错误。如何使用 Dataset API 方法解决此错误?任何帮助将不胜感激。

class AutoEncoder(Model):
  def _init_(self):
    super(AutoEncoder, self)._init_()
    #############
    ## ENCODER ##
    #############
    self.encoder = tensorflow1.keras.Sequential([
      tensorflow1.keras.layers.Dense(512, activation="relu"),
      tensorflow1.keras.layers.Dense(256, activation="relu"),
      tensorflow1.keras.layers.Dense(128, activation="relu"),
      tensorflow1.keras.layers.Dense(64, activation="relu"),
      tensorflow1.keras.layers.Dense(32, activation="relu"),
      tensorflow1.keras.layers.Dense(16, activation="relu")])

    #############
    ## DECODER ##
    #############
    self.decoder = tensorflow1.keras.Sequential([
      tensorflow1.keras.layers.Dense(32, activation="relu"),
      tensorflow1.keras.layers.Dense(64, activation="relu"),
      tensorflow1.keras.layers.Dense(128, activation="relu"),
      tensorflow1.keras.layers.Dense(256, activation="relu"),
      tensorflow1.keras.layers.Dense(512, activation="relu"),
      tensorflow1.keras.layers.Dense(600, activation="sigmoid")])
    
  def call(self, x):
    encoded = self.encoder(x)
    decoded = self.decoder(encoded)
    return decoded

model = AutoEncoder()

encoder_out = model.encoder(normal_test_data).numpy()

【问题讨论】:

标签: python tensorflow autoencoder


【解决方案1】:

这可能是一个旧帖子,但我遇到了同样的问题,因此,如果其他人正在搜索此问题,请关注评论#2: Failed copying input tensor from CPU to GPU in order to run GatherVe: Dst tensor is not initialized. [Op:GatherV2]

【讨论】:

    猜你喜欢
    • 2020-07-15
    • 2020-12-06
    • 1970-01-01
    • 2022-12-06
    • 1970-01-01
    • 2022-11-13
    • 2018-01-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多