【发布时间】:2020-09-13 00:48:23
【问题描述】:
我试图将一个函数传递给我的 tf 数据集以规范化我的数据框中的非数字数据,但是我不断收到此错误:
TypeError:在用户代码中: TypeError: tf__norm() 接受 1 个位置参数,但给出了 2 个
def norm(dataframe):
for header in dataframe._get_numeric_data().columns:
dataframe[header] = (dataframe[header] - dataframe[header].mean())/dataframe[header].std()
return dataframe
train, val= train_test_split( dataframe, test_size =0.2)
def df_to_dataset(dataframe, shuffle=True, batch_size=32):
dataframe = dataframe.copy()
labels = dataframe.pop("target")
ds = tf.data.Dataset.from_tensor_slices((dict(dataframe), labels))
if shuffle:
ds = ds.shuffle(buffer_size=len(dataframe))
ds = ds.batch(batch_size)
ds=ds.map(norm)
return ds
train_ds= df_to_dataset(train, shuffle=False, batch_size=32)
val_ds = df_to_dataset(val, shuffle=False)
【问题讨论】:
标签: tensorflow keras