mindspore-ai / mindspore

MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios.
https://gitee.com/mindspore/mindspore
Apache License 2.0
4.25k stars 703 forks source link

mindspore.nn.Conv1d and mindspore.nn.Conv1dtranspose 's shapes are four-dimensional #284

Open PhyllisJi opened 4 months ago

PhyllisJi commented 4 months ago

Environment

Hardware Environment(Ascend/GPU/CPU):

CPU and GPU

Software Environment:

Describe the current behavior

The parameter shapes of mindspore.nn.Conv1d and mindspore.nn.Conv1dtranspose are four-dimensional, causing the model to be unable to complete the reading of the parameters. The dimensions described in the official documentation are supposed to be three-dimensional, and other frameworks such as TensorFlow and PyTorch are also three-dimensional.

Describe the expected behavior

Their parameter shapes should be one-dimensional

Related log / screenshot

1621716100461_ pic_hd

VectorSL commented 1 week ago

你好。确实存在上述差异,MindSpore的Conv1d底层使用Conv2d算子实现,对于 kernel_size 等参数会在第0维进行自动补0操作,导致初始化的权重weight比PyTorch多一维,正常使用不感知,但涉及网络模型迁移时,通过参数加载的方式调用Conv1d可能会出现权重维度不一致的情况,需要用户手动对weight权重在对应维度上进行升维。 详见 conv1d差异faq