簡體   English   中英

我從 AutoEncoder tensorflow2.0 按時間順序得到錯誤的數據

[英]I get wrong data form AutoEncoder tensorflow2.0 Data in chronological order

我做了一個自動編碼器 model,並運行測試

  • 行為在我的形象中:
    • 輸入:7data * 88 寬度
    • output:7數據*88寬度
  • 行為真實
    • 輸入:7data * 88 寬度
    • output:7數據*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 使其工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM