【发布时间】:2020-01-20 00:25:16
【问题描述】:
我正在尝试一个 TF 模型,其中输入是字符串张量作为输入,我的模型包含一个用于文本处理的 TextVectorization 层,该层在 TF 2.2 中可用。
训练在 W&B 回调中失败并出现以下错误
TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
调试的时候发现问题出在权重直方图的计算过程中
> /usr/local/lib/python3.6/dist-packages/numpy/lib/histograms.py(325)_get_outer_edges()
323 else:
324 first_edge, last_edge = a.min(), a.max()
--> 325 if not (np.isfinite(first_edge) and np.isfinite(last_edge)):
326 raise ValueError(
327 "autodetected range of [{}, {}] is not finite".format(first_edge, last_edge))
ipdb> first_edge
b'0'
ipdb> last_edge
b'zurich'
ipdb> np.isfinite('0')
*** TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
这是我设置 W&B 回调和运行训练的方法
wandb_callback = wandb.keras.WandbCallback(log_weights=True)
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy')
model.fit(train_ds, validation_data=valid_ds, epochs=config.epochs, shuffle=True, verbose=1, callbacks=[wandb_callback])
我尝试使用wandb.keras.WandbCallback() 创建回调,但没有记录权重,但同样的问题,它一直在尝试计算直方图并在一个时期结束时失败。
知道这里有什么问题吗?
【问题讨论】:
标签: python tensorflow keras callback