machine-learning - 如何将Pytorch模型参数转换为长数据类型?

标签 machine-learning deep-learning pytorch

我能够将 pytorch 模型参数转换为 float 或 double,但不能转换为 long。

model = model.long() 

给出错误,而

model = model.float() 

运行。

我得到的错误是:

'Net' object has no attribute 'long'

最佳答案

大多数 nn 模块不支持长(整数)运算,例如卷积、线性层等。因此,您无法将模型“转换”为 torch.long .

关于machine-learning - 如何将Pytorch模型参数转换为长数据类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56921455/

相关文章:

python - 当分类器从测试文件进行预测时,为什么会有额外的标签?

python - 使用 Lab 时,transforms.Normalize() 介于 0 和 1 之间

machine-learning - 使用数据集训练模型

python - "AssertionError: Torch not compiled with CUDA enabled"尽管升级到 CUDA 版本

python - 如何从 pytorch 模型并行化模型预测?

machine-learning - 如何设置 SVM 检测的最佳阈值?

machine-learning - 有没有办法在 ml5 yolo() 中使用自定义模型?

python - 自动特征选择 - Sklearn.feature_selection

python - 使用 Keras、Python 纠正 CNN、基于 LSTM 的分类器的输入维度

python - Pytorch nn 模块泛化