繁体   English   中英

W&B Keras 回调类型错误:输入类型不支持 ufunc 'isfinite'

[英]W&B Keras callback TypeError: ufunc 'isfinite' not supported for the input types

我正在尝试一个 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()创建回调,但没有记录权重,但同样的问题,它一直试图计算直方图,但在一个时代结束时失败。

知道这里有什么问题吗?

你能分享你的实际模型代码吗? 看起来模型本身包含字符串张量。 通常,您会在通过网络之前将字符串转换为嵌入。 您在使用 TensorFlow 2 吗?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM