Tensorflow遇到的问题InvalidArgumentError: Graph execution error:2 root error(s) found.解决方法
生活随笔
收集整理的這篇文章主要介紹了
Tensorflow遇到的问题InvalidArgumentError: Graph execution error:2 root error(s) found.解决方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 遇到問題
- 解決
- 參考
遇到問題
平臺google colab
使用GPU
訓練dl模型時,遇到報錯
上述報錯由以下代碼產生
text_vectorization.adapt(text_only_train_ds)tfidf_2gram_train_ds = train_ds.map(lambda x, y: (text_vectorization(x), y),num_parallel_calls=4) tfidf_2gram_val_ds = val_ds.map(lambda x, y: (text_vectorization(x), y),num_parallel_calls=4) tfidf_2gram_test_ds = test_ds.map(lambda x, y: (text_vectorization(x), y),num_parallel_calls=4)model = get_model() model.summary() callbacks = [keras.callbacks.ModelCheckpoint("tfidf_2gram.keras",save_best_only=True) ] model.fit(tfidf_2gram_train_ds.cache(),validation_data=tfidf_2gram_val_ds.cache(),epochs=10,callbacks=callbacks) model = keras.models.load_model("tfidf_2gram.keras") print(f"Test acc: {model.evaluate(tfidf_2gram_test_ds)[1]:.3f}")解決
目前猜測應該用CPU訓練,而不是GPU。果然,將runtime type改為None即可
因為這里數據預處理使用CPU進行,而具體計算使用GPU,所以數據集應用CPU來做。
參考
https://github.com/tensorflow/tensorflow/issues/28007
總結
以上是生活随笔為你收集整理的Tensorflow遇到的问题InvalidArgumentError: Graph execution error:2 root error(s) found.解决方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: wsl 或者window termina
- 下一篇: 《算法竞赛进阶指南》打卡-基本算法-Ac