Анатолий П

Зарегистрирован с 31.08.2022
Комментарии
22 сентября 2022

Закомментируй BatchNormalization в дискриминаторе, должно помочь. Я хз почему так def build_discriminator(self):

функция создания блока CNN block для уменьшения размера изображения

def add_discriminator_block(x_block, filters):
    block = Conv2D(filters, filter_size, padding='same')(x_block)
    #block = BatchNormalization()(block)
    block = Conv2D(filters, filter_size, padding='same', strides=2)(block)
    #block = BatchNormalization()(block)
    block = LeakyReLU(0.3)(block)
    return block

start_filters = 16
filter_size = [5, 5]

#inp = Input(shape=(self.img_rows, self.img_cols, self.channels))
inp = Input(shape=(64, 64, self))

# строим дискриминатор для уменьшения изображения
x = add_discriminator_block(inp, start_filters)
x = add_discriminator_block(x, start_filters * 2)
x = add_discriminator_block(x, start_filters * 4)
x = add_discriminator_block(x, start_filters * 8)

# усреднение и возврат бинарного вывода
x = GlobalAveragePooling2D()(x)
x = Dense(1, activation='sigmoid')(x)

model = Model(inputs=inp, outputs=x)
print('discriminator')
model.summary()
return model
Ответить
03 сентября 2022

Не работает в гугл коллабе, при попытке запустить обучение пишет:

TypeError: You are passing KerasTensor(type_spec=TensorSpec(shape=(), dtype=tf.float32, name=None), name='Placeholder:0', description="created by layer 'tf.cast_9'"), an intermediate Keras symbolic input/output, to a TF API that does not allow registering custom dispatchers, such as tf.cond, tf.function, gradient tapes, or tf.map_fn. Keras Functional model construction only supports TF API calls that do support dispatching, such as tf.math.add or tf.reshape. Other APIs cannot be called directly on symbolic Kerasinputs/outputs. You can work around this limitation by putting the operation in a custom Keras layer call and calling that layer on this symbolic input/output.

Ответить