title: How to convert a list of strings into a tensor in pytorch?
body: <p>I am working on classification problem in which I have a list of strings as class labels and I want to convert them into a tensor. So far I have tried converting the list of strings into a <code>numpy array</code> using the <code>np.array</code> function provided by the numpy module. </p>
  
  <p><code>truth = torch.from_numpy(np.array(truths))</code></p>
  
  <p>but I am getting the following error.</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>Can anybody suggest an alternative approach? Thanks</p>