0
keras Conv2Dレイヤーに手動で入力したいと思います。kerasのConv2Dレイヤーの出力形状
私はMNISTデータセットを取ります。
Conv2Dはテンソルのみを受け入れるので、Input
ケラスのコマンドを使用してx_train
をx_train_tensor
に変更します。
(None, 26, 26, 32)
私は:私のようなものになるように出力を期待してい
(60000,128,128,1)
:
私の入力は
(samples,rows, cols,channels)
例入力keras命令で与えられたフォーマットであります取得:
shape=(?, 59998, 26, 32)
私は間違っていますか?
マイコード:
import keras
from keras.datasets import mnist
from keras.layers import Conv2D
from keras import backend as K
from keras.layers import Input
batch_size = 128
num_classes = 10
epochs = 1
# input image dimensions
img_rows, img_cols = 28, 28
# the data, shuffled and split between train and test sets
(x_train, y_train), (x_test, y_test) = mnist.load_data()
if K.image_data_format() == 'channels_first':
x_train = x_train.reshape(x_train.shape[0], 1, img_rows, img_cols)
x_test = x_test.reshape(x_test.shape[0], 1, img_rows, img_cols)
input_shape = (1, img_rows, img_cols)
else:
x_train = x_train.reshape(x_train.shape[0], img_rows, img_cols, 1)
x_test = x_test.reshape(x_test.shape[0], img_rows, img_cols, 1)
input_shape = (img_rows, img_cols, 1)
x_train = x_train.astype('float32')
x_test = x_test.astype('float32')
x_train /= 255
x_test /= 255
print('x_train shape:', x_train.shape)
print(x_train.shape[0], 'train samples')
print(x_test.shape[0], 'test samples')
x_train_tensor=Input(shape=(60000,28,28), name='x_train')
A=Conv2D(32, kernel_size=(3, 3),
activation='relu',
input_shape=input_shape)(x_train_tensor)