0

This line:

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

gives the error:

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

Has anyone any idea how can I solve it?

Vadim
  • 4,219
  • 1
  • 29
  • 44
  • Possible duplicate of [AttributeError: 'Tensor' object has no attribute '\_keras\_history'](https://stackoverflow.com/questions/44889187/attributeerror-tensor-object-has-no-attribute-keras-history) – Mathieu de Lorimier Oct 12 '17 at 14:59
  • 2
    Please include a complete example that produces this error. – Dr. Snoopy Oct 12 '17 at 15:02

1 Answers1

0

But I actually managed to avoid the problem. I gave z like an input to the function. I used Input layer for creating it.

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])