不過其實(shí)得到onehot編碼可以用pandas.get_dummies 1 2 index=[1,2,1,2,0] pd.get_dummies(index) .scatter_函數(shù) .scatter_函數(shù)放置元素或者修改元素。 1 2 3 4 5 6 7 8 9 10 11 12 >>> x=torch.rand(2,5) >>> x tensor([[0.6132,0.8931,0.7345,0.6793,0.6606], ...
www.dbjr.com.cn/python/297881n...htm 2025-5-27