#将某个矩阵中的负值变为0 neg = feats < 0.0 rows,cols,_ = scipy.sparse.find(neg) feats[rows,cols] = 0.0 #pickle.dump()和pickle.load()方法分别是将python对象序列化到文件中和从文件反序列化出对象 with open(file,'wb') as f: pkl.dump(obj,f) with open(file,'rb') as f: pkl.load(f)