[Python] bertmoticon.infer() sentence of Bertmoticon package not work

Discussão em 'Python' iniciado por Stack, Janeiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I have executed the following:


    • pip3 install bertmoticon


    • import bertmoticon


    • print(bertmoticon.infer(ls_of_strings, 3))

    And I obtained the following error:


    ---------------------------------------------------------------------------
    TypeError Traceback (most recent call last)
    <ipython-input-6-e7c02d1c5fb8> in <module>()
    ----> 1 print(bertmoticon.infer(ls_of_strings,3))

    2 frames
    /usr/local/lib/python3.7/dist-packages/bertmoticon/__init__.py in forward(self, x)
    136 input_ids, attention_mask = x
    137 last_layer,embedding = self.bert(input_ids)
    --> 138 embedding = torch.mean(last_layer,dim=1)
    139 out = self.fc_class(embedding)
    140 return out, None

    TypeError: mean() received an invalid combination of arguments - got (str, dim=int), but expected one of:
    * (Tensor input, *, torch.dtype dtype)
    * (Tensor input, tuple of names dim, bool keepdim, *, torch.dtype dtype, Tensor out)
    * (Tensor input, tuple of ints dim, bool keepdim, *, torch.dtype dtype, Tensor out)
    * List item
    * List item

    Continue reading...

Compartilhe esta Página