【发布时间】: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()
【问题讨论】:
-
你能减少来自
normal_test_data的样本数量并尝试吗?
标签: python tensorflow autoencoder