Giter Site home page Giter Site logo

ValueError: Dimensions must be equal, but are 15 and 11 for 'loss/mul' (op: 'Mul') with input shapes: [?,128,15], [?,128,11] about bert-chinese-ner HOT 7 CLOSED

prohiryu avatar prohiryu commented on August 22, 2024
ValueError: Dimensions must be equal, but are 15 and 11 for 'loss/mul' (op: 'Mul') with input shapes: [?,128,15], [?,128,11]

from bert-chinese-ner.

Comments (7)

taotao033 avatar taotao033 commented on August 22, 2024 5

你好,我把data文件夹中的数据换成自己的数据,为什么会报这样的错误呀?应该如何解决呀?谢谢分享

There are some parameters that need to be changed based on your data set. Based on my own data set, for example:

def get_labels(self): return ["O", "B-OBJ", "I-OBJ", "X", "[CLS]", "[SEP]"]

logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, 7])

precision = tf_metrics.precision(label_ids, predictions, 7, [2, 3], average="macro") recall = tf_metrics.recall(label_ids, predictions, 7, [2, 3], average="macro") f = tf_metrics.f1(label_ids, predictions, 7, [2, 3], average="macro")

After do this, remember to clean up the contents of the directory 'output/results_dir'

I hope I can help you.

from bert-chinese-ner.

yuye2133 avatar yuye2133 commented on August 22, 2024 5

logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, 11]) 这句应该改成:
logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, num_labels])
因为每个人的labels不一样,如果直接写11的话就会报错了

from bert-chinese-ner.

sxk000 avatar sxk000 commented on August 22, 2024

thanks very much !it works for me ! but there is another problem when i run again.

InvalidArgumentError (see above for traceback): assertion failed: [labels out of bound] [Condition x < y did not hold element-wise:] [x (confusion_matrix_1/control_dependency:0) = ] [13 1 1...] [y (ToInt64_5:0) = ] [11]
[[{{node confusion_matrix_1/assert_less/Assert/AssertGuard/Assert}} = Assert[T=[DT_STRING, DT_STRING, DT_STRING, DT_INT64, DT_STRING, DT_INT64], summarize=3, _device="/job:localhost/replica:0/task:0/device:CPU:0"](confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/Switch/_1299, confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/data_0, confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/data_1, confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/data_2, confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/Switch_1/_1301, confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/data_4, confusion_matrix_1/assert_less/Assert/AssertGuard/Assert/Switch_2/_1303)]]

How can I solve it ? thanks!

from bert-chinese-ner.

kFoodie avatar kFoodie commented on August 22, 2024

ValueError: Dimension size must be evenly divisible by 5500 but is 112000 for 'loss/Reshape_1' (op: 'Reshape') with input shapes: [16000,7], [3] and with input tensors computed as partial shapes: input[1] = [?,500,11].
我用自己的数据的时候,也报了这样的错。

from bert-chinese-ner.

kFoodie avatar kFoodie commented on August 22, 2024

额,我改成7就好了。logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, 7])

from bert-chinese-ner.

wshzd avatar wshzd commented on August 22, 2024

我执行原代码,数据也是data文件夹中的,但是还是会报错,改成logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, 7])也不行
ValueError: Dimension size must be evenly divisible by 896 but is 40960 for 'loss/Reshape_1' (op: 'Reshape') with input shapes: [4096,10], [3] and with inp
ut tensors computed as partial shapes: input[1] = [?,128,7].

from bert-chinese-ner.

wshzd avatar wshzd commented on August 22, 2024

具体关于shape方面的报错,我把下面代码中的11修改为10就好了
logits = tf.reshape(logits, [-1, FLAGS.max_seq_length, 10])
precision = tf_metrics.precision(label_ids,predictions,10,[2,3,4,5,6,7],average="macro")
recall = tf_metrics.recall(label_ids,predictions,10,[2,3,4,5,6,7],average="macro")
f = tf_metrics.f1(label_ids,predictions,10,[2,3,4,5,6,7],average="macro")

from bert-chinese-ner.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.