gpt4 book ai didi

python - model.save 收到 Not JSON Serialized 错误。 tensorflow 1.14.0

转载 作者:行者123 更新时间:2023-11-30 09:58:20 25 4
gpt4 key购买 nike

我尝试实现一个简单的架构

def conv_block_A(layer):
block = tf.keras.layers.Conv2D(filters=128, kernel_size=3, strides=1, padding='same')(layer)
block = tf.keras.layers.Conv2D(filters=196, kernel_size=3, strides=1, padding='same')(block)
block = tf.keras.layers.Conv2D(filters=128, kernel_size=3, strides=1, padding='same')(block)
block = tf.keras.layers.BatchNormalization(momentum=0.8)(block)
block = tf.keras.layers.LeakyReLU(alpha=0.2)(block)

return block

def PoolingAndDense(input):
dense = tf.keras.layers.GlobalAveragePooling2D(data_format='channels_last')(input)
dense = tf.keras.layers.Dense(units=64)(dense)
dense = tf.keras.layers.LeakyReLU(alpha=0.2)(dense)
dense = tf.keras.layers.Dense(units=32)(dense)
dense = tf.keras.layers.LeakyReLU(alpha=0.2)(dense)
dense = tf.keras.layers.Dense(units=1)(dense)
dense = tf.keras.activations.sigmoid(dense)
return dense


input_shape = input_shape
input_layer = tf.keras.layers.Input(shape=input_shape,dtype="float32")
stem = tf.keras.layers.Conv2D(filters=64, kernel_size=5, strides=1, padding='same')(input_layer)
first_conv_block_output = conv_block_A(stem)
mtss = PoolingAndDense(first_conv_block_output)
Model = tf.keras.Model(inputs=input_layer, outputs=mtss)

但是 model.save 不适用于tensorflow 1.14,但适用于 1.15 我如何使其适用于 1.14?

最佳答案

经过tensorflow documentations之后对于代码中的每一行,我都进行了更改

dense = tf.keras.activations.sigmoid(dense)

tf.keras.layers.Dense(units=1, activation='sigmoid')(dense)

关于python - model.save 收到 Not JSON Serialized 错误。 tensorflow 1.14.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60109630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com