ravel()とreshape(-1)の違いがわからないです。
Numpyの勉強をしています。
ravel()とreshape(-1)は両方、多次元配列を一次元配列にする見方を変えているだけ、と習ったのですが、
厳密な違いは何なのでしょうか?
(本当に同じ役割のメソッドが2つ存在するわけがないので)
例えば、以下のコードを勉強しました。
# coding: utf-8 from __future__ import absolute_import from __future__ import division from __future__ import print_function import os import numpy as np import numpy.random as random a = np.arange(12).reshape(3,4) print(a) b1 = a.flatten() b2 = a.ravel() b3 = a.reshape(-1) print(b1) print(b2) print(b3)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。