Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tensorflow 自动编码器中卷积层输出的可视化_Tensorflow_Keras_Keras Layer - Fatal编程技术网

Tensorflow 自动编码器中卷积层输出的可视化

Tensorflow 自动编码器中卷积层输出的可视化,tensorflow,keras,keras-layer,Tensorflow,Keras,Keras Layer,我有一个简单的自动编码器,我想看到每一层的输出,特别是潜在空间。我知道在每一层之后都会获得一些特征,比如边缘,但我想显示每一层的输出。我想知道每一层的输出是什么,确切地说,我想在我的自动编码器中可视化每一层的输出。我该怎么做?我该怎么做? 因为我对我的网络没有真正的想象力,我想知道网络的每一层都发生了什么。我真的需要它。请帮我解决这个问题。我在等你的消息 from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling

我有一个简单的自动编码器,我想看到每一层的输出,特别是潜在空间。我知道在每一层之后都会获得一些特征,比如边缘,但我想显示每一层的输出。我想知道每一层的输出是什么,确切地说,我想在我的自动编码器中可视化每一层的输出。我该怎么做?我该怎么做? 因为我对我的网络没有真正的想象力,我想知道网络的每一层都发生了什么。我真的需要它。请帮我解决这个问题。我在等你的消息

from keras.layers import Input, Dense, Conv2D, MaxPooling2D, UpSampling2D
from keras.models import Model
from keras import backend as K
from keras.datasets import mnist
import numpy as np
input_img = Input(shape=(28, 28, 1))  # adapt this if using `channels_first` image data format

x = Conv2D(16, (3, 3), activation='relu', padding='same')(input_img)
x = MaxPooling2D((2, 2), padding='same')(x)
x = Conv2D(8, (3, 3), activation='relu', padding='same')(x)
x = MaxPooling2D((2, 2), padding='same')(x)
x = Conv2D(8, (3, 3), activation='relu', padding='same')(x)
encoded = MaxPooling2D((2, 2), padding='same')(x)

# at this point the representation is (4, 4, 8) i.e. 128-dimensional

x = Conv2D(8, (3, 3), activation='relu', padding='same')(encoded)
x = UpSampling2D((2, 2))(x)
x = Conv2D(8, (3, 3), activation='relu', padding='same')(x)
x = UpSampling2D((2, 2))(x)
x = Conv2D(16, (3, 3), activation='relu')(x)
x = UpSampling2D((2, 2))(x)
decoded = Conv2D(1, (3, 3), activation='sigmoid', padding='same')(x)

autoencoder = Model(input_img, decoded)
autoencoder.compile(optimizer='adadelta', loss='binary_crossentropy')

#train part


(x_train, _), (x_test, _) = mnist.load_data()

x_train = x_train.astype('float32') / 255.
x_test = x_test.astype('float32') / 255.
x_train = np.reshape(x_train, (len(x_train), 28, 28, 1))  # adapt this if using `channels_first` image data format
x_test = np.reshape(x_test, (len(x_test), 28, 28, 1))  # adapt this if using `channels_first` image data format
from keras.callbacks import TensorBoard

autoencoder.fit(x_train, x_train,
                epochs=50,
                batch_size=128,
                shuffle=True,
                validation_data=(x_test, x_test),
                callbacks=[TensorBoard(log_dir='/tmp/autoencoder')])
用于可视化输出


你期望的第一层(有很多直线等等)。祝你一切顺利

我使用Keras时可能会重复,我是一个初学者,那么我应该在Keras中做什么呢?我想以图像的形式显示中间层的输出,我该如何做?请提供一个示例代码或一个包含示例代码的链接,因为我不熟悉keras的专业知识。是的,我读过,但它使用VGG。我想拥有我的网络并在mnist上显示我的结果!?嗨,没人能帮我吗?我还看到了这个关于显示中间层的链接。但是我不明白什么是x,我应该用什么来代替它?请告诉我现在该怎么办?我知道这很简单,但我是个初学者;(X是你的唯一。你看过我发送的链接了吗?概念相同,但深入讨论。如果你更改了代码,你应该更新你的问题以反映这一点。如果更改非常大,你应该打开一个新的、更具体的问题