赞
踩
之前提过在model的fit中使用 dataset
参考链接:https://blog.csdn.net/qq_24677259/article/details/108166601
现在继续熟悉一下multi output和multi loss,多输出多损失函数
keras的函数式模型主要用于多输入多输出任务,输出按顺序对应损失函数list,在dataset构建时也要分为一个tuple含两个元素,分别对应输入和输出
dataset = tf.data.Dataset.from_tensor_slices((x_train, (y_train,y_train))).batch(32)
例子如下
- from tensorflow.keras.datasets import cifar10
- from tensorflow.keras import Model
- from tensorflow.keras.layers import Conv2D,MaxPool2D,Flatten,Dense,Input
- from tensorflow.keras.utils import to_categorical
- from tensorflow.keras.optimizers import Adam
- from tensorflow.keras.losses import mean_squared_error,categorical_crossentropy
- import numpy as np
- import tensorflow as tf
- gpus = tf.config.experimental.list_physical_devices('GPU')
- tf.config.experime
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。