0

I am working on an interesting project, which requires I use the huber function on a set of variables and just the square function on the other variables. For example, I have a vector function looking like this f(x, z) = (H(x),S(z)), where H(x) is the huber function with a specified parameter and S(z) is the square function.

Ultimately, x, z are parts of x_bar. I am wondering if anyone knew of any unique way to do this in function, without indexing the arrays, i.e. x,z = x_bar[:n],x_bar[n:].

Thank you for your help.

EDIT:

I am sorry for the confusion.

Firstly, I will start with the inputs to my functions. I have a vector called x_bar, which I have defined to be the concatentation of two different vectors x and z. These vectors can belong to different dimensional spaces. Let us say x is a n-dimensional vector and z is a m-dimensional vector.

Secondly, I am defining (x,z) to be concatentation of the vectors x and z. So when I wrote f(x,z) = ( H(x), S(z) ), I am stating that f(x,z) is the concatenation of H(x) and S(z). Please assume H(x) is a vector-valued function and S(z) is a vector valued function, still performing the operators I specified in the original comment.

Thirdly, I am writing a custom loss function in python and I was hoping to use x_bar as my primary input and setting x, z = x_bar[:n], x_bar[n:], where x_bar[:n] is slicing the array and referencing only the first n components.

Ed Turner
  • 1
  • 2
  • This is a bit unclear. Could you please clarify by specifying your input (`x_bar` and `n`?) and desired output (the tuple `(H(x, delta), z*z)` or perhaps its concatenation?)? Do you have just one `n` or multiple `n`s? Etc. – Paul Panzer Jan 25 '18 at 05:05
  • 1
    It looks like you have an interesting problem, but you haven't formulated it in a way we can really help much with. Please show us what the function *should* do, using the `x,z = x_bar[:n],x_bar[n:]` method you want to remove, so that we can help you. This is called a [mcve], please read about it and also [ask]. – Daniel F Jan 25 '18 at 07:50
  • I updated the question above. – Ed Turner Jan 27 '18 at 02:32
  • It sounds like you've already solved your problem, with `x,z = x_bar[:n],x_bar[n:]`. What's going wrong? Do you encounter some error? – John Zwinck Jan 27 '18 at 02:45
  • As you work on parts of the vector, why not just slice them and concat later? Also the question is still not clear. If you ask more clearly, people could hopefully provide ready-to-use answer. – THN Jan 27 '18 at 02:45

0 Answers0