2017-10-12 91 views
0

這行:當我產生噪音張我得到這個錯誤:AttributeError的:「張量」對象有沒有屬性「_keras_history」

z = random_normal(shape = (-1, 8, 8, 256), 
        mean = 0.0, stddev = 1.0, dtype = None, seed = None) 

給出了錯誤:

AttributeError: 'Tensor' object has no attribute '_keras_history'. 

有任何人任何我怎麼能解決它?

+0

的可能的複製[AttributeError的: '張量' 對象沒有屬性 '\ _keras \ _history'](https://stackoverflow.com/questions/44889187/attributeerror-tensor-object-has-no-attribute -keras-history) –

+2

請包含產生此錯誤的完整示例。 –

回答

0

但我真的設法避免了這個問題。我給了z一樣的功能輸入。我使用輸入層來創建它。

image = Input(shape = (128, 128, 3)) 
noise = random_normal(shape = (-1, 8, 8, 100), mean = 0.0, stddev = 1.0, dtype = None, seed = None) 
noise = Input(tensor = noise) 

gen_out = generator_network(image, noise) 
gen_model = Model(inputs = [image, noise], outputs = gen_out) 

def generator_network(input_tensor, noise): 
    """ 
    The generator network, G has two pathways, with one global network Gg processing 
    the global structure of the face and a local one for the main face features: eyes, 
    mouth, nose. Each path has an encoder - decoder structure with skip connections. 
    :INPUT : Input tensor corresponding to an image, a face profile. 
    :OUTPUT: Output tensor that corresponds to the frontal face. 
    """ 
    # Global pathway encoder 
    conv0 = Conv2D(filters = 64, kernel_size = (7, 7), padding = 'same', strides = (1, 1))(input_tensor) 
    conv0 = BatchNormalization()(conv0) 
    conv0 = LeakyReLU(0.2)(conv0) 
    conv0 = resnet_block(conv0, 64) 

    conv1 = Conv2D(filters = 64, kernel_size = (5, 5), padding = 'same', strides = (2, 2))(conv0) 
    conv1 = BatchNormalization()(conv1) 
    conv1 = LeakyReLU(0.2)(conv1) 
    conv1 = resnet_block(conv1, 64) 

    conv2 = Conv2D(filters = 128, kernel_size = (3, 3), padding = 'same', strides = (2, 2))(conv1) 
    conv2 = BatchNormalization()(conv2) 
    conv2 = LeakyReLU(0.2)(conv2) 
    conv2 = resnet_block(conv2, 128) 

    conv3 = Conv2D(filters = 256, kernel_size = (3, 3), padding = 'same', strides = (2, 2))(conv2) 
    conv3 = BatchNormalization()(conv3) 
    conv3 = LeakyReLU(0.2)(conv3) 
    conv3 = resnet_block(conv3, 256) 

    conv4 = Conv2D(filters = 512, kernel_size = (3, 3), padding = 'same', strides = (2, 2))(conv3) 
    conv4 = BatchNormalization()(conv4) 
    conv4 = LeakyReLU(0.2)(conv4) 
    for i in range(4): 
     conv4 = resnet_block(conv4, 512) 

    fc1 = Dense(512)(conv4) 
    f1 = Lambda(lambda x: x[:, : , :, 0:256])(fc1) 
    f2 = Lambda(lambda x: x[:, : , :, 256:512])(fc1) 
    fc2 = maximum([f1, f2]) 

    # Concatenation with noise vector 
    v = concatenate([fc2, noise]) 
相關問題