コーヒー買ってきて☕
*メモ:
- 私の投稿では atleast_2d() について説明しています。
- 私の投稿では atleast_3d() について説明しています。
atleast_1d() は、1 つ以上の 0D テンソルを 1 つ以上の 0D テンソルから 1 つ以上の 1D テンソルに変更するだけで、0 個以上の要素の 1 つ以上の 1D または複数の D テンソルのビューを取得できます。以下に示すように、0 個以上の要素:
*メモ:
- atleast_1d() はトーチでは使用できますが、テンソルでは使用できません。
- torch の 1 つ目以上の引数は *tensors(Required-Type: int、float、complex、bool のテンソル、タプル、または int、float、complex、bool のテンソルのリスト) です。
*メモ:
- 複数のテンソルを設定する場合は、テンソルのタプルが返され、それ以外の場合はテンソルが返されます。
- *tensors=、tensor、input などのキーワードは使用しないでください。
- 引数を設定しないと空のタプルが返されます。
import torch tensor0 = torch.tensor(2) # 0D tensor torch.atleast_1d(tensor0) # tensor([2]) tensor0 = torch.tensor(2) # 0D tensor tensor1 = torch.tensor([2, 7, 4]) # 1D tensor tensor2 = torch.tensor([[2, 7, 4], [8, 3, 2]]) # 2D tensor tensor3 = torch.tensor([[[2, 7, 4], [8, 3, 2]], # 3D tensor [[5, 0, 8], [3, 6, 1]]]) tensor4 = torch.tensor([[[[2, 7, 4], [8, 3, 2]], # 4D tensor [[5, 0, 8], [3, 6, 1]]], [[[9, 4, 7], [1, 0, 5]], [[6, 7, 4], [2, 1, 9]]]]) torch.atleast_1d(tensor0, tensor1, tensor2, tensor3, tensor4) torch.atleast_1d((tensor0, tensor1, tensor2, tensor3, tensor4)) # (tensor([2]), # tensor([2, 7, 4]), # tensor([[2, 7, 4], [8, 3, 2]]), # tensor([[[2, 7, 4], [8, 3, 2]], # [[5, 0, 8], [3, 6, 1]]]), # tensor([[[[2, 7, 4], [8, 3, 2]], # [[5, 0, 8], [3, 6, 1]]], # [[[9, 4, 7], [1, 0, 5]], # [[6, 7, 4], [2, 1, 9]]]])) tensor0 = torch.tensor(2) # 0D tensor tensor1 = torch.tensor([2, 7, 4]) # 1D tensor tensor2 = torch.tensor([[2., 7., 4.], # 2D tensor [8., 3., 2.]]) tensor3 = torch.tensor([[[2.+0.j, 7.+0.j, 4.+0.j], # 3D tensor [8.+0.j, 3.+0.j, 2.+0.j]], [[5.+0.j, 0.+0.j, 8.+0.j], [3.+0.j, 6.+0.j, 1.+0.j]]]) tensor4 = torch.tensor([[[[True, False, True], [False, True, False]], [[True, False, True], [False, True, False]]], [[[True, False, True], [False, True, False]], [[True, False, True], [False, True, False]]]]) # 4D tensor torch.atleast_1d(tensor0, tensor1, tensor2, tensor3, tensor4) # (tensor([2]), # tensor([2, 7, 4]), # tensor([[2., 7., 4.], # [8., 3., 2.]]), # tensor([[[2.+0.j, 7.+0.j, 4.+0.j], # [8.+0.j, 3.+0.j, 2.+0.j]], # [[5.+0.j, 0.+0.j, 8.+0.j], # [3.+0.j, 6.+0.j, 1.+0.j]]]), # tensor([[[[True, False, True], [False, True, False]], # [[True, False, True], [False, True, False]]], # [[[True, False, True], [False, True, False]], # [[True, False, True], [False, True, False]]]])) torch.atleast_1d() # ()
以上がatleast_in PyTorchの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

inpython、youappendelementStoalistusingtheappend()method.1)useappend()forsingleelements:my_list.append(4).2)useextend()or = formultipleElements:my_list.extend(another_list)ormy_list = [4,5,6] .3)forspecificpositions:my_list.insert(1,5).beaware

シェバンの問題をデバッグする方法には次のものがあります。1。シバン行をチェックして、それがスクリプトの最初の行であり、接頭辞スペースがないことを確認します。 2.通訳パスが正しいかどうかを確認します。 3.通訳を直接呼び出してスクリプトを実行して、シェバンの問題を分離します。 4. StraceまたはTrustsを使用して、システムコールを追跡します。 5.シバンに対する環境変数の影響を確認してください。

pythonlistscanbemanipulatedsingseveralmethodstoremoveElements:1)theremove()methodremovesthefirstoccurrenceofaspecifiedValue.2)thepop()methop()methodremovessanelementatagivenindex.3)thedelstatementementementementementementementementementemoritemoricedex.4)

Integers、strings、floats、booleans、otherlists、anddictionaryを含むpythonlistscanstoreanydatype

PythonListsSupportNumersoperations:1)AddingElementSwithAppend()、Extend()、Andinert()

Numpyを使用して多次元配列を作成すると、次の手順を通じて実現できます。1)numpy.array()関数を使用して、np.array([[1,2,3]、[4,5,6]])などの配列を作成して2D配列を作成します。 2)np.zeros()、np.ones()、np.random.random()およびその他の関数を使用して、特定の値で満たされた配列を作成します。 3)アレイの形状とサイズの特性を理解して、サブアレイの長さが一貫していることを確認し、エラーを回避します。 4)np.reshape()関数を使用して、配列の形状を変更します。 5)コードが明確で効率的であることを確認するために、メモリの使用に注意してください。

BroadcastinginNumPyisamethodtoperformoperationsonarraysofdifferentshapesbyautomaticallyaligningthem.Itsimplifiescode,enhancesreadability,andboostsperformance.Here'showitworks:1)Smallerarraysarepaddedwithonestomatchdimensions.2)Compatibledimensionsare

Forpythondatastorage、chooseLists forfficability withmixeddatypes、array.arrayformemory-efficienthogeneousnumericaldata、およびnumpyArrays foradvancednumericalcomputing.listSareversatilebuteficient efficient forlargeNumericaldatates;


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

PhpStorm Mac バージョン
最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

ホットトピック









