我正在学习在Jupyter Notebook中编写我的第一个CNN-GAN代码。我已经创建了Generator,并且工作正常。但是,在keras中使用conv3d定义我的Discriminator网络时,出现了此错误。我尝试将我的keras后端设置为Theano,但没有成功。任何帮助,不胜感激。在此附上我的代码作为参考。
#Creating the discriminator network (setting up hyperparameters)
dis_input_shape=(64,64,64,1)
dis_filters=[64,128,256,512,1]
dis_kernel_sizes=[4,4,4,4,4]
dis_strides=[2,2,2,2,1]
dis_paddings=['same','same','same','same','valid']
dis_alphas=[0.2,0.2,0.2,0.2,0.2]
dis_activations= ['leaky_relu','leaky_relu','leaky_relu','leaky_relu','sigmoid']
dis_convolutional_blocks=5
from keras.layers import Input
from keras import backend as K #Tried setting backend to Theano at this point, still didn't help
K.set_image_dim_ordering('th')
dis_input_layer=Input(shape=dis_input_shape)
#The first 3D Convolution block (This runs fine with no errors)
from keras.layers import Conv3D
from keras.layers import BatchNormalization
from keras.layers import LeakyReLU
a=Conv3D(filters=dis_filters[0],
kernel_size=dis_kernel_sizes[0],
strides=dis_strides[0],
padding=dis_paddings[0])(dis_input_layer)
a=BatchNormalization()(a, training=True)
a=LeakyReLU(dis_alphas[0])(a)
#The next 4 3D Convolution Blocks (This is the code chunk with the error)
from keras.layers import Activation
from keras import backend as K
K.set_image_dim_ordering('th')
for i in range(dis_convolutional_blocks-1):
a=Conv3D(filters=dis_filters[i+1],
kernel_size=dis_kernel_sizes[i+1],
strides=dis_strides[i+1],
padding=dis_paddings[i+1])(a)
a=BatchNormalization()(a,training=True)
if dis_activations[i+1]=='leaky_relu':
a=LeakyReLU(dis_alphas[i+1])(a)
elif dis_activations[i+1]=='sigmoid':
a=Activation(activation='sigmoid')(a)