numpy array 数字范围设定
在处理 mnist 数据库,把数据库的数组加一发现,数组范围还是 [0, 255];发现把256的数切片加一等于零? 原来是 mnist 数据库数组的数据类型是 “uint8”,最多256个数,把数据类型改成 “int” 成功使数组加一 mnist = tf . keras . datasets . mnist ( x_train , y_train ) , ( x_test , y_test ) = mnist . load_data ( ) x_train = x_train . reshape ( 60000 , - 1 ) x_test = x_test . reshape ( 10000 , - 1 ) x_train = x_train . astype ( int ) x_train = x_train + 1 x_train . min ( ) x_train . max ( ) 输出 1 256 来源: CSDN 作者: 调羹(勾) 链接: https://blog.csdn.net/weixin_43414981/article/details/103456453