Giter VIP home page Giter VIP logo

Comments (4)

Liwb5 avatar Liwb5 commented on August 17, 2024

我看GATNE的作者也是用TruncatedNormalInitializer初始化的呢.

from pgl.

zzs95 avatar zzs95 commented on August 17, 2024

我看GATNE的作者也是用TruncatedNormalInitializer初始化的呢.

我的意思是,create_parameter这个api的初始化变量应该是default_initializer,不是attr

应该是就是这样

trans_weights = fl.create_parameter(
    shape=[
        self.edge_type_count, self.embedding_u_size,
        self.embedding_size // self.att_head
    ],
    **default_initializer**=fluid.initializer.TruncatedNormalInitializer(
        loc=0.0, scale=1.0 / math.sqrt(self.embedding_size)),
    dtype='float32',
    name='trans_w')

要不然就报错

TypeError: The type of 'attr' in create_parameter must be (<class 'NoneType'>, <class 'paddle.fluid.param_attr.ParamAttr'>), but received <class 'paddle.fluid.initializer.TruncatedNormalInitializer'>.

attr 输入的应该是属性对象ParamAttr
default_initializer 输入的才是fluid.initializer

from pgl.

Liwb5 avatar Liwb5 commented on August 17, 2024

噢噢, 感谢提醒. 我修改一下.

from pgl.

zzs95 avatar zzs95 commented on August 17, 2024

也可以把初始化封装成属性对象,就可以用attr变量传参了

import paddle.fluid as fluid
import math
import paddle.fluid.layers as layers
W = layers.create_parameter(shape=[784, 200], dtype='float32',attr=fluid.ParamAttr(initializer=fluid.initializer.MSRAInitializer(uniform=False)))

from pgl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.