NotImplementedError: Cannot convert a symbolic Tensor (bert/encoder/layer_0/attention/self/strided_slice:0) to a numpy array. This error may indicate that you’re trying to pass a Tensor to a NumPy call, which is not supported问题解决
问题原因这里显示的是,np.square()方法中不能加入张量,因为格式转换不了
解决方法我使用的是tensorflow2.6.0和numpy1.19.5。在网上查询解决方法时基本上都说改变numpy的版本可以解决,我换了好几个还是不行,后来决定从格式方面来解决,总不至于tensorflow的创作者会忽略这个问题,于是尝试了一下方法
z = tf.compat.v1.multiply(tf.compat.v1.square(X), w2) + tf.compat.v1.multiply(X, w1) + b



