內容目錄
前言
在機器學習的領域中,我們經常用的資料格式就是 tensor,
我們有時會需要宣告一個空的tensor,來幫助我們初始化 tensor 的資料型態。
可以想想看,我們有時不是也會先宣告一個空的list
然後再把東西慢慢的 append 進去嗎?
範例程式碼
import torch
a = torch.tensor([])
print(a)
print(a.shape)
內容目錄
在機器學習的領域中,我們經常用的資料格式就是 tensor,
我們有時會需要宣告一個空的tensor,來幫助我們初始化 tensor 的資料型態。
可以想想看,我們有時不是也會先宣告一個空的list
然後再把東西慢慢的 append 進去嗎?
import torch
a = torch.tensor([])
print(a)
print(a.shape)