无力吐槽的废酱的几个问题

hi我是菜鸟小明哥。真就与世无争了吗??自甘堕落了吗?整天一大堆群,也没推广出去。不好用,不实用。

bug1,这是我help后出来的例子,下面我亲自跑一下

>>> help(fluid.layers.argsort)

    Examples:
        .. code-block:: python
    
            import paddle.fluid as fluid
            import numpy as np
    
            in1 = np.array([[[5,8,9,5],
                            [0,0,1,7],
                            [6,9,2,4]],
                            [[5,2,4,2],
                            [4,7,7,9],
                            [1,7,0,6]]]).astype(np.float32)
            with fluid.dygraph.guard():
                x = fluid.dygraph.to_variable(in1)
                out1 = fluid.layers.argsort(input=x, axis=-1)
                out2 = fluid.layers.argsort(input=x, axis=0)
                out3 = fluid.layers.argsort(input=x, axis=1)
                print(out1[0].numpy())
                # [[[5. 5. 8. 9.]
                #   [0. 0. 1. 7.]
                #   [2. 4. 6. 9.]]
                #  [[2. 2. 4. 5.]
                #   [4. 7. 7. 9.]
                #   [0. 1. 6. 7.]]]
                print(out1[1].numpy())
                # [[[0 3 1 2]
                #   [0 1 2 3]
                #   [2 3 0 1]]
                #  [[1 3 2 0]
                #   [0 1 2 3]
                #   [2 0 3 1]]]

如下,鬼知道哪里错了

in1 = np.random.randn(4,5).astype(np.float32)

with fluid.dygraph.guard():
    x = fluid.dygraph.to_variable(in1)
    out1 = fluid.layers.argsort(input=x, axis=-1)

>>> out1
Traceback (most recent call last):
  File "", line 1, in 
    out1
  File "D:pythonlibidlelibrpc.py", line 621, in displayhook
    text = repr(value)
  File "C:Usersxulm1AppDataRoamingPythonPython36site-packagespaddlefluidframework.py", line 563, in __str__
    return self.to_string(True)
  File "C:Usersxulm1AppDataRoamingPythonPython36site-packagespaddlefluidframework.py", line 587, in to_string
    protostr = self.desc.serialize_to_string()
AttributeError: 'Variable' object has no attribute 'desc'

bug2

inputs=np.random.randn(4,5)
print(inputs)
x = fluid.layers.data(name='x', shape=[-1,5], dtype='float32')
softmax = fluid.layers.softmax(input=x, name='SoftMax',axis=-1)
exe = fluid.Executor(fluid.CPUPlace())
results=exe.run(fluid.default_main_program(),feed={x:inputs},fetch_list=softmax)

Traceback (most recent call last):
  File "D:/python/pycode/paddle_softmax_.py", line 19, in 
    results=exe.run(fluid.default_main_program(),feed={x:inputs},fetch_list=softmax)
  File "C:Usersxulm1AppDataRoamingPythonPython36site-packagespaddlefluidexecutor.py", line 657, in run
    use_program_cache=use_program_cache)
  File "C:Usersxulm1AppDataRoamingPythonPython36site-packagespaddlefluidexecutor.py", line 751, in _run
    fetch_var_name=fetch_var_name)
  File "C:Usersxulm1AppDataRoamingPythonPython36site-packagespaddlefluidexecutor.py", line 421, in _add_feed_fetch_ops
    out = global_block.var(name)
  File "C:Usersxulm1AppDataRoamingPythonPython36site-packagespaddlefluidframework.py", line 1556, in var
    (type(name)))
TypeError: var require string as parameter, but get  instead.

差劲。难用。

本文由 @不成功的猿人[Vip] 发布于 职涯宝 ,未经作者许可,禁止转载,欢迎您分享文章

发表评论

登录后才能评论
小程序
小程序
微信客服
微信客服
QQ客服 建站服务
分享本页
返回顶部