pytorch concatenate code example

Example 1: torch concat matrix

third_tensor = torch.cat((first_tensor, second_tensor), 0) # keep column width append in rows

third_tensor = torch.cat((first_tensor, second_tensor), 1) # keep row height and append in columns

Example 2: python concatenate strings

x = ‘apples’
y = ‘lemons’
z = “In the basket are %s and %s” % (x,y)

Example 3: string concatenation in python

x="String"
y="Python"
d="+"
c = "We can concatenation " + y + x + "with" + d + "Operator"
print(c)