concatenate function
Implementation
Tensor<Vector> concatenate(Tensor<Vector> a, Tensor<Vector> b) {
Vector outValue = [...a.value, ...b.value];
Tensor<Vector> out = Tensor<Vector>(outValue);
out.creator = Node(
[a, b],
() {
int aLength = a.value.length;
for (int i = 0; i < aLength; i++) {
a.grad[i] += out.grad[i];
}
for (int i = 0; i < b.value.length; i++) {
b.grad[i] += out.grad[aLength + i];
}
},
opName: 'concat_vector', // <-- Renamed for clarity
cost: 0,
);
return out;
}