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

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 "<pyshell#115>", line 1, in <module>
    out1
  File "D:\python\lib\idlelib\rpc.py", line 621, in displayhook
    text = repr(value)
  File "C:\Users\xulm1\AppData\Roaming\Python\Python36\site-packages\paddle\fluid\framework.py", line 563, in __str__
    return self.to_string(True)
  File "C:\Users\xulm1\AppData\Roaming\Python\Python36\site-packages\paddle\fluid\framework.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 <module>
    results=exe.run(fluid.default_main_program(),feed={x:inputs},fetch_list=softmax)
  File "C:\Users\xulm1\AppData\Roaming\Python\Python36\site-packages\paddle\fluid\executor.py", line 657, in run
    use_program_cache=use_program_cache)
  File "C:\Users\xulm1\AppData\Roaming\Python\Python36\site-packages\paddle\fluid\executor.py", line 751, in _run
    fetch_var_name=fetch_var_name)
  File "C:\Users\xulm1\AppData\Roaming\Python\Python36\site-packages\paddle\fluid\executor.py", line 421, in _add_feed_fetch_ops
    out = global_block.var(name)
  File "C:\Users\xulm1\AppData\Roaming\Python\Python36\site-packages\paddle\fluid\framework.py", line 1556, in var
    (type(name)))
TypeError: var require string as parameter, but get <class 'paddle.fluid.framework.Variable'> instead.

差劲。难用。

猜你喜欢

转载自blog.csdn.net/SPESEG/article/details/108639384