gpt4 book ai didi

How to use correctly TextToSequences in python(如何在PYTHON中正确使用TextToSequence)

转载 作者:bug小助手 更新时间:2023-10-28 11:17:39 26 4
gpt4 key购买 nike



Here is a python script :

以下是一个PYTHON脚本:


from zeugma import TextsToSequences

test = ['I am here to stay', 'Who are you', 'Hello World']

sequencer = TextsToSequences()
embedded_sequ = sequencer.fit_transform(test)

It return this error :

它返回以下错误:


ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

How to solve this issue?

如何解决这个问题?


I try to give the same length to each element of test.

我试着给测试的每个元素赋予相同的长度。


I expected to have a list of number for the return

我本以为会有一份退货的号码清单


更多回答

More detail, I used this library : from zeugma import TextsToSequences

更详细地说,我使用了这个库:从zeugma导入TextsToSequence

优秀答案推荐

Convert it into list of words:

将其转换为单词列表:


test = [['I', 'am', 'here', 'to', 'stay'], ['Who', 'are', 'you'], ['Hello', 'World']]

sequencer = TextsToSequences()
embedded_sequ = sequencer.fit_transform(test)

更多回答

I tried it. I have this output error : ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

我试过了。我有这样的输出错误:ValueError:使用序列设置数组元素。请求的数组在%1维后具有不均匀形状。检测到的形状为(3,)+不均匀部分。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com