Is there a more elegant / performant / built-in way to do this? Thanks in advance.
"Apply each function in f_array to each element of the corresponding row."
function func_array_eachrow!(W, f_array)
for i=1:size(W,1)
W[i, :] = f_array[i].(W[i, :])
end
end
W = rand(3,4)
@show W
func_array_eachrow!(W, [sin, cos, sqrt])
@show W
The application is to use a different activation function for each output from a Flux layer.
4 posts - 3 participants