- 博客(5)
- 收藏
- 关注
原创 python - .view()
A = torch.arange(0, 16) print(A) B = A.view(-1,2) print(B) C = A.view(-1,2,2) print(C)
2019-10-15 14:03:46
8496
原创 python日常学习 - iloc
设矩阵A A.iloc[n:m, 0] 取矩阵所有行第一列元素 A.iloc[0, :] 取矩阵所有列第一行元素 示例: import numpy as np import pandas as pd data = pd.DataFrame(np.arange(16).reshape(4,4)) print(data, '\n') print(data.iloc[2:4, 0], '\n') p...
2019-09-22 18:50:25
788
原创 python - dtype
dtype 查看数组元素类型 astype 改变数组元素类型 import math import numpy as np import pandas as pd A = np.array(pd.DataFrame(np.arange(16).reshape(4,4))) print(A) print(A.dtype) print(A.astype(np.float)) print(A.a...
2019-09-22 18:50:17
813
原创 Python - asarray
np.array会创建副本,占用新内存 np.asarray不会,仅使用原数据内存 实例: import math import numpy as np import pandas as pd A = np.array(pd.DataFrame(np.arange(16).reshape(4,4))) print(A) B = np.asarray(A) A[1] = 0 print(A) ...
2019-09-22 18:50:07
264
原创 Python - torch与numpy的转换
// An highlighted block var foo = 'bar'; Out: 注意两种转换都不占用新内存,即一个数据改变,转换的其他都会改变 示例: import math import torch import numpy as np import pandas as pd A = np.array(pd.DataFrame(np.arange(16).reshape(4,4)...
2019-09-22 18:49:54
2549
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人