目标是从TensorFlow数据集中训练猫狗数据集,我需要将数据转换为图像和标签。我需要构建一个函数,从TensorFlow数据集的“功能”返回图像和标签,并从中创建训练数据集。有关详细信息,请运行代码
基础设施将所有图像调整为224x224,颜色深度为3字节。确保您的输入层将图像训练到该规格
代码:
import tensorflow_datasets as tfds
import tensorflow as tf
dataset_name = 'cats_vs_dogs'
dataset, info = tfds.load(name=dataset_name, split=tfds.Split.TRAIN, with_info=True)
def preprocess(features):
// this is where the code must be.
def solution_model():
train_dataset = dataset.map(preprocess).batch(32)
在这里,我将对模型进行编码,并将训练数据集作为输入
这是解决办法