tensorflow2.0 一个模型输出不同类型的结果

def net_one(_input):
        h1 = tf.keras.layers.Conv2D(24, 5, strides=2, padding="same",  activation='relu')(_input)
        h1 = tf.keras.layers.MaxPool2D(2, strides=2)(h1)
        h1 = tf.keras.layers.Conv2D(32, 3, strides=2, padding="same", activation='relu')(h1)
        h1 = tf.keras.layers.MaxPool2D(2, strides=2)(h1)
        h1 = tf.keras.layers.Conv2D(64, 3, strides=2, padding="same",  activation='relu')(h1)
        h1 = tf.keras.layers.MaxPool2D(2)(h1)
        # h1 = tf.keras.layers.AveragePooling2D(2, strides=2)(h1)
        h1 = tf.keras.layers.Flatten()(h1)
        h1 = tf.keras.layers.Dense(128, activation='tanh')(h1)
        h1 = tf.keras.layers.Dropout(0.1)(h1)
        h1 = tf.keras.layers.Dense(64, activation='tanh')(h1)
        h1 = tf.keras.layers.Dropout(0.1)(h1)
        
        output1 = Dense(1, activation='linear', name='output1')(x)
		output2 = Dense(1, activation='linear', name='output2')(x)

		model = Model(input=image_input, output=[output1, output2])
		model.compile(optimizer='adam', loss={
     'output1': 'mean_squared_error', 'output2': 'mean_squared_error'})

        return model
        
input_shape = (_width, _height, _chanal)
        # 定义输入
_input = tf.keras.Input(shape=input_shape)        
model = net_one(_input)

# 训练  y_train=[y_train1,y_train2].
model.fit_generator(batch_generator(X_train, y_train, batch_size))

你可能感兴趣的:(AI,人工智能,#,tensorflow)