使用 TensorFlow 预构建估计器进行分类和回归
1. 输入函数(Input Function)
输入函数的目的是为估计器模型对象返回以下两个对象:
- 一个字典,键为特征名称,值为包含相应特征数据的张量(Tensors)或稀疏张量(Sparse Tensors)。
- 一个包含一个或多个标签的张量。
基本结构如下:
def input_fn (dataset):
# create dictionary with feature names
# and Tensors with corresponding data
# create Tensor for label data
return dictionary, label
实际的输入函数示例:
def input_fn(features, labels, training = True, batch_size = 32):
#converts inputs to a dataset
Dataset = tf.data.Dataset.from_tensor_slices((dict(features),labels))
return dataset.batch(batch_size)
2. 预构建估计器(Premade Estimators)
我们将讨论两种预构建估计器,一种用于分类问题,另一种用于回归问题
超级会员免费看
订阅专栏 解锁全文
1450

被折叠的 条评论
为什么被折叠?



