【发布时间】:2021-03-04 23:36:51
【问题描述】:
我几天来一直在寻找解决此错误的方法,但找不到解决方法:
NotFoundError: 3 root error(s) found.
(0) Not found: No algorithm worked!
[[node model/conv1d/conv1d (defined at /lib/python3.6/threading.py:916) ]]
[[div_no_nan/ReadVariableOp_1/_678]]
(1) Not found: No algorithm worked!
[[node model/conv1d/conv1d (defined at /lib/python3.6/threading.py:916) ]]
(2) Not found: No algorithm worked!
[[node model/conv1d/conv1d (defined at /lib/python3.6/threading.py:916) ]]
[[Adam/concat_4/_704]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_152439]
Function call stack:
train_function -> train_function -> train_function
我正在尝试通过将 BERT 与 this 之类的分类器相结合来构建自己的模型,但在分类器中实现 Keras 1D ConvLayer 时遇到了一些问题。
我正在使用Tensorflow 2.4.1 和Python 3.6.9。
nvcc --version 的输出为:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Wed_Jul_22_19:09:09_PDT_2020
Cuda compilation tools, release 11.0, V11.0.221
Build cuda_11.0_bu.TC445_37.28845127_0
有什么建议吗?这是我的第一个问题,如果需要更多信息,请通知我。
重现错误的最少代码:
import numpy as np
import shutil
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_text as text
tfhub_handle_encoder = 'https://tfhub.dev/tensorflow/bert_en_uncased_L-12_H-768_A-12/3'
tfhub_handle_preprocess = 'https://tfhub.dev/tensorflow/bert_en_uncased_preprocess/3'
input_train = np.array([['this is such an amazing movie!'],
['Fat son how smiling mrs natural expense anxious friends. Boy scale enjoy ask abode fanny being son. As material in learning subjects so improved feelings'],
['Now indulgence dissimilar for his thoroughly has terminated. Agreement offending commanded my an. Change wholly say why eldest period.'],
[' Are projection put celebrated particular unreserved joy unsatiable its. In then dare good am rose bred or. On am in nearer square wanted. ']
])
y_train = np.array([0,0,1,0])
input_test = np.array([['Prevailed sincerity behaviour to so do principle mr. As departure at no propriety zealously my. On dear rent if girl view. First on smart there he sense.'],
[' Delicate say and blessing ladyship exertion few margaret. Delight herself welcome against smiling its for. Suspected discovery by he affection household of principle perfectly he.'],
['In to am attended desirous raptures declared diverted confined at. Collected instantly remaining up certainly to necessary as.'],
['Over walk dull into son boy door went new. At or happiness commanded daughters as. Is handsome an declared at received in extended vicinity subjects.']
])
y_val = np.array([1,0,1,1])
def build_classifier_model():
text_input = tf.keras.layers.Input(shape=(), dtype=tf.string, name='text')
preprocessing_layer = hub.KerasLayer(tfhub_handle_preprocess, name='preprocessing')
encoder_inputs = preprocessing_layer(text_input)
encoder = hub.KerasLayer(tfhub_handle_encoder, trainable=True, name='BERT_encoder')
outputs = encoder(encoder_inputs)
net = outputs['sequence_output']
net = tf.keras.layers.Dropout(0.1)(net)
net = tf.keras.layers.Conv1D(512,5,activation='relu',strides=1)(net)
net = tf.keras.layers.Dense(1, activation=None, name='classifier')(net)
return tf.keras.Model(text_input, net)
strategy = tf.distribute.MirroredStrategy()
with strategy.scope():
classifier_model = build_classifier_model()
Adam = tf.keras.optimizers.Adam(lr=0.0002)
classifier_model.compile(loss='sparse_categorical_crossentropy', optimizer=Adam, metrics=['accuracy'])
history = classifier_model.fit(
x = input_train,
y= y_train,
validation_data=(input_test, y_val),
epochs=5,
verbose=1,
)
input_train、input_test、y_train和y_val是随机值,但错误是一样的。
【问题讨论】:
-
似乎有许多问题会导致此错误或类似错误,包括代码错误和 cuda 问题。请参阅此处的示例:github.com/keras-team/keras/issues/7226 如果您可以创建一个小代码示例(请参阅minimal reproducible example)来演示您遇到的问题并将edit 放入问题中,那就太好了。
-
按要求添加了一个最小的可重现示例,如果需要其他内容请通知
-
有人可以运行代码吗?
标签: python tensorflow keras tensorflow2.0 bert-language-model