我想在 mps 设备上运行零样本分类任务的管道摘要。这是我的代码
pipe = pipeline('zero-shot-classification', device = mps_device)
seq = "i love watching the office show"
labels = ['negative', 'positive']
pipe(seq, labels)
Run Code Online (Sandbox Code Playgroud)
产生的错误是
RuntimeError: Placeholder storage has not been allocated on MPS device!
Run Code Online (Sandbox Code Playgroud)
我的猜测是因为 seq 在我的 cpu 上而不是 mps 上。我怎样才能解决这个问题 ?有没有办法将 seq 发送到 mps 设备,以便我可以将其传递到管道进行推理?
谢谢
我有一组来自 CSV 文件中标签列的整数 - [1,2,4,3,5,2,..]. 类的数量即5范围为1到6。我想使用下面的代码对它们进行一次性编码。
y = df.iloc[:,10].values
y = tf.keras.utils.to_categorical(y, num_classes = 5)
y
Run Code Online (Sandbox Code Playgroud)
但是这段代码给了我一个错误
IndexError: index 5 is out of bounds for axis 1 with size 5
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?