Tensor concatenation and appending #2669
Answered
by
laggui
wangjiawen2013
asked this question in
Q&A
-
Hi, let tensor1 = Tensor::<NdArray, 1>::from_floats([1,2,3]);
let tensor2 = Tensor::<NdArray, 1>::from_floats([4,5,6]);
// expected tensor3 [1,2,3,4,5,6]
let tensor3 = tensor1 concat tensor2 let mut tensor = Tensor::<NdArray, 1>::from_floats([1,2,3]);
// expected tensor [1, 2, 3, 4]
tensor.append(4) |
Beta Was this translation helpful? Give feedback.
Answered by
laggui
Jan 8, 2025
Replies: 1 comment
-
Both manipulations can be accomplished with let tensor1 = Tensor::<B, 1>::from([1, 2, 3]);
let tensor2 = Tensor::<B, 1>::from([4, 5, 6]);
let tensor3 = Tensor::cat(vec![tensor1, tensor2], 0); let tensor1 = Tensor::<B, 1>::from([1, 2, 3]);
let tensor2 = Tensor::<B, 1>::from([4]);
let tensor3 = Tensor::cat(vec![tensor1, tensor2], 0); |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
laggui
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Both manipulations can be accomplished with
Tensor::cat
for concatenating.