MxNet学习笔记(1)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/xiaomifanhxx/article/details/85259876

1  mxnet.ndarray.concat

import mxnet.ndarray as nd
x=[[1,1],[2,2]]
y=[[3,3],[4,4],[5,5]]
z=[[6,6],[7,7],[8,8]]
nd.concat(x,y,z,dim=0)##按行拼接
nd.concat(y,z,dim=1)##按列拼接

2  Python中*和**的区别

当要使函数接收元组或字典形式的参数 的时候,有一种特殊的方法,它分别使用*和**前缀 。这种方法在函数需要获取可变数量的参数 的时候特别有用。

[1] 由于在args变量前有*前缀 ,所有多余的函数参数都会作为一个元组存储在args中 。如果使用的是**前缀 ,多余的参数则会被认为是一个字典的健/值对 。
[2] 对于def func(*args):,*args表示把传进来的位置参数存储在tuple(元组)args里面。例如,调用func(1, 2, 3) ,args就表示(1, 2, 3)这个元组 。
[3] 对于def func(**args):,**args表示把参数作为字典的健-值对存储在dict(字典)args里面。例如,调用func(a='I', b='am', c='wcdj') ,args就表示{'a':'I', 'b':'am', 'c':'wcdj'}这个字典 。
[4] 注意普通参数与*和**参数公用的情况,一般将*和**参数放在参数列表最后。

2.1  元组的情形


def powersum(power, *args):  
    '''''Return the sum of each argument raised 
to specified power.'''  
      
    total=0  
    for i in args:  
        total+=pow(i,power)  
    return total  
print 'powersum(2, 3, 4)==', powersum(2, 3, 4)  
print 'powersum(2, 10)==', powersum(2, 10)  
########  
# output  
########  
powersum(2, 3, 4)==25  
powersum(2, 10)==100   

2.2  字典的情形


def findad(username, **args):  
    '''''find address by dictionary'''  
    print 'Hello: ', username  
    for name, address in args.items():  
        print 'Contact %s at %s' % (name, address)  
findad('wcdj', gerry='[email protected]', /  
        wcdj='[email protected]', yj='[email protected]'  

3  数据增强

    数据增强时,可以采用Python库原带的Albumentations

    参考网站:https://www.aiuai.cn/aifarm422.html

4  白化作用(提高准确率,asscalar)(查看论文)

未完待续

扫描二维码关注公众号,回复: 4799616 查看本文章

猜你喜欢

转载自blog.csdn.net/xiaomifanhxx/article/details/85259876
今日推荐