numpy ndarray.reshape()(返回一个数组,其中包含具有新形状的相同数据)(不会改变原数据)
发布日期:2021-05-10 09:12:50 浏览次数:19 分类:精选文章

本文共 1260 字,大约阅读时间需要 4 分钟。

��� NumPy ��������������������������� reshape ������������������

            def reshape(self, shape, order='C'):
"""a.reshape(shape, order='C')
������������������������������������������������������
��������� `NumPy reshape` ������������������������
"""
pass

������������

# -*- coding: utf-8 -*-
"""
@File : 20200310_python_test.py
@Time : 2020/3/10 23:29
@Author : Dontla
@Email : sxana@qq.com
@Software: PyCharm
"""
import numpy as np
# ������������ 1���������
a = np.array([1, 2, 3, 4, 5, 6])
# ������ reshape ������������������������ 2���3���
b = a.reshape(2, 3)
# ������������������
print("���������������", a) # ���������[1 2 3 4 5 6]
# ������������������������
print("���������������������")
print(b) # ���������
# [
# [1 2 3]
# [4 5 6]
# ]
# ���������������������������
print("���������������������", id(a)) # ���������2080594380720
print("���������������������������", id(b)) # ���������2080595240640
上一篇:360浏览器如何打开开发者模式?(浏览器兼容模式下按F12)
下一篇:pytorch torch.item()(返回此张量的值作为标准Python数字。 这仅适用于具有一个元素的张量。)

发表评论

最新留言

能坚持,总会有不一样的收获!
[***.219.124.196]2025年03月31日 22时43分26秒