hatimwen / paddle_pit Goto Github PK
View Code? Open in Web Editor NEW基于Paddle实现PiT ——Rethinking Spatial Dimensions of Vision Transformers
基于Paddle实现PiT ——Rethinking Spatial Dimensions of Vision Transformers
Hi,开发者你好,由于飞桨API之前对0维Tensor的支持不完善,通过shape为[1]的1D Tensor来替代shape为[]的0D Tensor,因此在很多本应输出0维tensor的场景中,实际输出的是1维tensor(如:loss)。目前飞桨计划全面支持0维tensor,在大多数情况下不会有不兼容问题,但也发现少量情况可能会报错。
目前发现 会报错 的代码是:loss.numpy()[0]
。原因是此前loss为1D Tensor(错误的语义),运行loss.numpy()[0]可以将其转化为python float数据。在loss被修改为0D Tensor(正确的语义)后,此操作会报错。需要将所有 loss.numpy()[0]
修改为 float(loss)
,以避免后续版本的代码错误。
因此请麻烦修改:
Tensor.numpy()[0]
修改为 float(Tensor)
,对当前不会有影响,亦可适应未来变化。感谢贡献代码。Hi, Developer, Due to the poor support for the 0D tensor in Paddle API. In many case, the output 1D tensor which shoulde be 0D Tensor (such as loss) are used by mistake. Paddle is plan to support 0D tensor fully, which will not cause incompatibility in most cases. However, it is also found that some code will report error.
This code is: loss.numpy()[0]
。 The reason is that the loss was 1D Tensor (wrong) before, it can be used as loss.numpy()[0]
. After the loss is modified to 0D Tensor (correct), the operation will result in an error. Therefore, it is needed to modify loss.numpy()[0]
to float(loss)
, to avoid errors in future paddle version.
Therefore, please modify:
Tensor.numpy()[0]
to float (Tensor)
, It will not affect the current situation, but also adapt to future. Thank you for contributing code.A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.