Message Boards Message Boards

GROUPS:

Error in Mathematica 12, BERT example?

Posted 10 months ago
1995 Views
|
6 Replies
|
2 Total Likes
|

Any idea why I am getting the following error in Mathematica 12 running a BERT example?

input = "Hello world! I am here";
embeddings = 

  NetModel["BERT Trained on BookCorpus and English Wikipedia Data"][
   input];

NetChain::invindata3: Data supplied to port "Input" could not be encoded; "Function" encoder did not produce an output that was a n*2 matrix of integers between 1 and 30522.![enter image description here][1]
6 Replies

It works for me, could you please ResourceRemove the ResourceObject and re-download the model?

In[1]:= input = "Hello world! I am here";
Dimensions@
 NetModel["BERT Trained on BookCorpus and English Wikipedia Data"][
  input]

Out[2]= {8, 768}
Posted 10 months ago

Hi Tuseeta,

I have the same problem. I tried

ResourceRemove[
 ResourceObject[
  "BERT Trained on BookCorpus and English Wikipedia Data"]]

Quit the kernel

input = "Hello world! I am here";
net = NetModel["BERT Trained on BookCorpus and English Wikipedia Data"]
net[input]

NetChain::invindata3: Data supplied to port "Input" could not be encoded; "Function" encoder did not produce an output that was a n*2 matrix of integers between 1 and 30522.

Other examples from the documentation also do not work as expected e.g.

net = NetModel[{"BERT Trained on BookCorpus and English Wikipedia Data", "InputType" -> "ListOfStrings"}];
netencoder = NetExtract[net, "Input"]
netencoder[{"Hello world!", "I am here"}]

Result is

Developer`NumericArrayQ[{{{102, 1}, {7593, 1}, {2089, 1}, {1000, 1}, {103, 1}, {1046, 2}, {2573, 2}, {2183, 2}, {103, 2}}}]

The result should be

{{102, 1}, {7593, 1}, {2089, 1}, {1000, 1}, {103, 1}, {1046, 2}, {2573, 2}, {2183, 2}, {103, 2}}

I am running

$Version
(* 12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019) *)

Any suggestions?

Thanks, Rohit

Can you try this? PacletUpdate["NeuralNetworks"] Quit and retry?

Posted 10 months ago

Hi Tuseeta,

I tried your suggestion, it did not solve the problem. Same error message.

Posted 10 months ago

Hi Tuseeta,

Do you have any other suggestions to try and fix this problem?

BTW it works fine on 12.1 prerelease version 12.1.0 for Mac OS X x86 (64-bit) (December 21, 2019)

Thanks, Rohit

Posted 10 months ago

Hi,

I just checked an example from above using Mathematica 12 / Win 10 64bit. While running the code example the first time Mathematica automatically executed updates and eventually produced the result as expected by Rohit. See the notebook attached.

Regards

Walter

Attachments:
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract