torch.repeat()
PyTorch中的repeat()函数可以对张量进行重复扩充。
>>> a= torch.arange(24).reshape(1,2,3,4) >>> print(a.size()) torch.Size([1, 2, 3, 4]) >>> print("b.size",a.repeat(2,2,2,2).size()) b.size torch.Size([2, 4, 6, 8]) >>> print("b.size",a.repeat(2,2).size) Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: Number of dimensions of repeat dims can not be smaller than number of dimensions of tensor
 
                    
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号