pytorch奇怪错误

ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array  with array.copy().) 

今天在这里遇到了一个奇怪的bug

import numpy as np

# 创建一个简单的数组
array = np.array([1, 2, 3, 4, 5])

# 使用反向切片创建负步幅数组
reversed_array = array[::-1]

print("原始数组:", array)
print("反向切片后的数组:", reversed_array)
print("反向数组的步幅:", reversed_array.strides)

结果如下

import torch 
aa = torch.FloatTensor(array)
bb = torch.FloatTensor(reversed_array)

正确用法

import torch 
aa = torch.FloatTensor(array)
bb = torch.FloatTensor(reversed_array.copy())

这个结果是

相关推荐
CITY_OF_MO_GY几秒前
Spark-TTS:基于大模型的文本语音合成工具
人工智能·深度学习·语音识别
阿丢是丢心心7 分钟前
【从0到1搞懂大模型】神经网络的实现:数据策略、模型调优与评估体系(3)
人工智能·深度学习·神经网络
新智元7 分钟前
10²⁶参数,AGI 还需 70 年!清华人大预测届时 GPU 总价达 4000 万倍苹果市值
人工智能·openai
何大春14 分钟前
【对话推荐系统综述】Broadening the View: Demonstration-augmented Prompt Learning for CR
论文阅读·人工智能·深度学习·语言模型·prompt·论文笔记
WenGyyyL15 分钟前
使用OpenCV和MediaPipe库——增强现实特效(在手腕添加虚拟手表)
人工智能·opencv·计算机视觉·ar·cv·mediapipe
东临碣石8218 分钟前
【英伟达AI论文】多模态大型语言模型的高效长视频理解
人工智能·语言模型·自然语言处理
我去热饭19 分钟前
【完整记录】基于腾讯云HAI+DeepSeek快速开发法律咨询(小律师)辅助平台过程
人工智能
CoovallyAIHub20 分钟前
一码难求的Manus,又对计算机视觉产生冲击?复刻开源版已在路上!
人工智能·深度学习·计算机视觉
是理不是里_21 分钟前
人工智能里的深度学习指的是什么?
人工智能·深度学习