我在运行此代码时遇到了让keras工作的问题:
from keras.layers import Conv2D,UpSampling2D,MaxPooling2D
import keras
(x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data()
x_test = x_test.reshape(-1,28,28,1)
x_train = x_train.reshape(-1,28,28,1)
def caev1():
input_shape = (28,28,1)
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu',padding = '
same',input_shape=input_shape))
model.add(MaxPooling2D(pool_size = (2,2),padding = 'valid'))
#(14,14,32)
model.add(Conv2D(16, kernel_size=(3, 3), activation='relu',padding =
'same'))
model.add(MaxPooling2D(pool_size = (2,2),padding = 'valid'))
#(7,7,16)
model.add(Conv2D(16, kernel_size=(3, 3), activation='relu',padding =
'same'))
model.add(UpSampling2D())
#(14,4,16)
model.add(Conv2D(32, kernel_size=(3, 3), activation='relu',padding =
'same'))
model.add(UpSampling2D())
#(28,28,16)
model.add(Conv2D(1,3,activation = 'sigmoid',padding = 'same'))
model.compile(optimizer='adam', loss='binary_crossentropy')
return model
m = caev1()
m.fit(x_train, x_train,epochs = 1, batch_size = 128, validation_data =
(x_test,x_test))
我收到此错误
2018-03-24 14:00:56.136200: E C:\tf_jenkins\workspace\rel-win\M\windows-
gpu\PY\36\tensorflow\stream_executor\cuda\cuda_dnn.cc:378] Loaded runtime
CuDNN library: 7101 (compatibility version 7100) but source was compiled
with 7003 (compatibility version 7000). If using a binary install, upgrade
your CuDNN library to match. If building from sources, make sure the
library loaded at runtime matches a compatible version specified during
compile configuration.
2018-03-24 14:00:56.138654: F C:\tf_jenkins\workspace\rel-win\M\windows-
gpu\PY\36\tensorflow\core\kernels\conv_ops.cc:717] Check failed: stream-
>parent()->GetConvolveAlgorithms(
conv_parameters.ShouldIncludeWinogradNonfusedAlgo<T>(), &algorithms)
所以从理论上讲我遇到了cudnn版本的问题,但是当运行另一个非常相似的代码(完全连接的层而不是conv)时,错误不会发生并且它完美地运行