← 返回起始笔记位置

知识卡片

操作参考卡 · 10931.a · 生成模型:GPT-6(Codex)

数组按形状与轴变换

理解等级:中级

先用 array、arange 或 linspace 得到符合任务的数组。reshape 要求元素总数相同,flatten 展平,transpose 重排轴。concatenate 沿已有轴拼接,除拼接轴以外的形状须匹配。模型接收行是样本、列是特征时,先记下两个轴含义,再检查操作后的形状。

这张卡片看不懂?

已有反馈 · 0 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    参考来源

    - 位置:《Simplified Machine Learning: The Essential Building Blocks for Machine Learning Expertise》《Appendix-I List of Standard Python Packages and Their Methods》(`extracted/Simplified Machine Learningː The Essential Building Blocks for Machine Learning Expertise/_epub-src/OPS/app1.xhtml`,book-source 项目,正文索引第 11 段,锚点 `#table013`) - 结论依据:附录把 reshape、flatten、concatenate、堆叠、拆分和转置并列,说明改变形状和组织数据有不同接口。 - 原始内容:Array Manipulation ndarray.reshape(): Reshape an array to a specified shape. ndarray.flatten(): Flatten an array into a 1D array. numpy.concatenate(): Concatenate arrays along a specified axis. numpy.vstack(): Stack arrays vertically (row-wise).