gpt4 book ai didi

python - 我从 AutoEncoder tensorflow2.0 数据中按时间顺序得到了错误的数据

转载 作者:太空宇宙 更新时间:2023-11-03 20:07:52 24 4
gpt4 key购买 nike

我做了一个自动编码器模型,并运行测试

  • 行为在我的印象中:
    • 输入:7数据* 88宽度
    • 输出:7数据* 88宽度
  • 行为真实
    • 输入:7数据* 88宽度
    • 输出:7data * 88 * 88

如何解决这个问题帮助我;;

环境:tensorflow2.0

代码

import tensorflow as tf

from tensorflow.keras.layers import Dense, Flatten, Conv2D
from tensorflow.keras import Model

from matplotlib import pyplot as plt #プロット

# create model
width = 88
%matplotlib inline
class MyModel(Model):
def __init__(self):
super(MyModel, self).__init__()

self.d1 = Dense(width, activation='tanh')
self.d2 = Dense(width/8, activation='tanh')
self.d3 = Dense(width, activation='tanh')

def call(self, x):
x = self.d1(x)
x = self.d2(x)
return self.d3(x)
model3 = MyModel()

# create dataset (TOO easy)
import numpy as np
def f(x):
x = x/width
return x

arange = np.arange(0,width,1)
if 'test' in locals():
del test
for j in range(7):

x = []
for i in range(len(arange)):
x.append(f(arange[i]))

if 'test' in locals():
test = np.vstack([test,x])
else:
test = x
plt.plot(x)

test= test[..., tf.newaxis]

# run test
print(model3(test).numpy().shape)

回答

output shape: (7, 88, 88)

最佳答案

将数据类型 numpy 更改为 tf.tensor 使其工作。

关于python - 我从 AutoEncoder tensorflow2.0 数据中按时间顺序得到了错误的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58872976/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com