<p>我正在研究分类问题,在这个问题中,我有一个字符串列表作为类标签,我想把它们转换成张量。到目前为止,我已经尝试使用numpy模块提供的<code>np.array</code>函数将字符串列表转换为<code>numpy array</code>。</p>
<p><code>truth = torch.from_numpy(np.array(truths))</code></p>
<p>但我有以下错误。</p>
<p><code>RuntimeError: can't convert a given np.ndarray to a tensor - it has an invalid type. The only supported types are: double, float, int64, int32, and uint8.</code></p>
<p>有人能提出另一种方法吗?谢谢</p>