λ vector on Tensor CP Decomposition with Alternating Least Square - tensor

I am trying to understand the procedure of tensor cp decomposition with alternating least squares based on this paper.
At page 464 is referred that "It is often useful to assume that the columns of A, B, and C are normalized to length one with the weights absorbed into the vector λ "
In addition, at page 471 line 7 of psedo code is "
normalize columns of A(n) (storing norms as λ)
"
I don't understand what values will be stored on vector λ and on matrix Λ.
What i understand is that we do normalization to ever column of the factor matrices and we store norms on a new vector λ
For example for a 3x3x3 tensor with rank=3, will have three 3x3 factors A,B and C and after normalize to unit length every column of all these matrices, i will end up with 9 norms. These norms will be the values of the diagonal matrix Λ ?
Am i missing something?
Thank you
Tensor CP Decomposition with Alternating Least Square.

I'm not familiar with the paper, but it looks like this is probably what they mean:
Suppose we're looking at the 3x3 case, since that's easy to draw. We have
fixed, non-normalized matrices $A,B,C$ and want matrices $a_r, b_r, c_r$ that are column normalized, and some matrix $\lambda$ s.t. $A B C = \lambda a_r b_r c_r$
\lambda A =
/ a1 b1 c1 \ / x1 x2 x1 \ / a1 x1 + b1 y1 + c1 z1; a1 x2 + b1 y2 + c1 z2; ... \
| a2 b2 c2 | | y1 y2 y2 | = | a2 x1 + b2 y1 + c2 z1; ... |
\ a3 b3 c3 / \ z1 z2 z3 / \ a3 x1 + b3 y1 + c3 z1; ... /
Then solve the following system of linear equations for $(a b c)$ to enforce the column-normalization of $\lambda A$:
/1\ / (a1+a2+a3) x1 + (b1+b2+b3) y1 + (c1+c2+c3) z1 \
|1| = | (a1+a2+a3) x2 + (b1+b2+b3) y2 + (c1+c2+c3) z2 |
\1/ \ (a1+a2+a3) x3 + (b1+b2+b3) z2 + (c1+c2+c3) z3 /
We've technically got too many free variables here, but since we only care about the sum of, e.g., $a1+a2+a3$, and not
what any individual a is, we'll just enforce the constraint that $\lambda$ be a diagonal matrix, at which point we have:
/1\ / a1 x1 + b2 y1 + c3 z1 \
|1| = | a1 x2 + b2 y2 + c3 z2 |
\1/ \ a1 x3 + b2 z2 + c3 z3 /
We plug that into a linear equation solver to get values for $a1,b2,c3$. We then do the same thing for B and C and multiply all the lambdas together (taking advantage of the associativity of matrix multiplication to pull them all to the left),
at which point $A B C = \lambda a_r b_r c_r$, and all the $foo_r$ matrices have normalized columns.

Related

The output of a shallow multilayer network, with linear activation function in each of the neurons, is linear in the weights -> FALSE?

Can anyone prove to me why the above sentence is FALSE?
I have the feeling that being all linear units I can always write W(Linear) = Y for any W, but the teacher says it's False and quoted a student that said:
The output y of said shallow network is y=sum(v)* sum(wTx +b), so we have the product of the weights v and w inside the output. So the output is non linear in respect to the weights
Could anyone be more precise/analytical?
Consider the following neural network:
x1 -- h1
\/ \ y
/\ /
x2 -- h2
Corresponding to the following equations:
h1 = w11 x1 + w12 x2
h2 = w21 x1 + w22 x2
y = v1 h1 + v2 h2
Here the weights are w11, w12, w21, w22, v1, v2.
Combining the three equations, we get:
y = v1 w11 x1 + v1 w12 x2 + v2 w21 x1 + v2 w22 x2
Hence we can say that y is a bilinear function of (w11, w12, w21, w22) and (v1, v2), but we cannot say that y is a linear function of (w11, w12, w21, w22, v1, v2).

Substitute variable in Maxima

newbie Maxima question
I have a transfer function in Maxima
E1 : y = K_i*s/(s^2 + w^2);
I'd like to have the closed-form of the equation affter applying the bilinear transform
E2 : s = (2/Ts*(z-1)/(z+1));
I would like to get the transfer function for z, by substituing s by equation E2. How should I proceed?
Regards
Note that subst can apply one or more substitutions stated as equations. In this case, try subst(E2, E1).
That will probably create a messy result -- you can simplify it somewhat by applying ratsimp to the result.
Here's what I get from that.
(%i2) E1 : y = K_i*s/(s^2 + w^2);
K_i s
(%o2) y = -------
2 2
w + s
(%i3) E2 : s = (2/Ts*(z-1)/(z+1));
2 (z - 1)
(%o3) s = ----------
Ts (z + 1)
(%i4) subst (E2, E1);
2 K_i (z - 1)
(%o4) y = ------------------------------
2
4 (z - 1) 2
Ts (z + 1) (------------ + w )
2 2
Ts (z + 1)
(%i5) ratsimp (%);
2
2 K_i Ts z - 2 K_i Ts
(%o5) y = -----------------------------------------------
2 2 2 2 2 2 2
(Ts w + 4) z + (2 Ts w - 8) z + Ts w + 4

Vector substitution

I have a huge dynamic system in wxmaxima, and I need to do some vector substitution but it ends up just with some crazy results. This is what I need to do:
forces:[
F1=[x1,y1,z1],
F2=[x2,y2,z2]
];
equations:[F3=-F2];
subst(forces,subst(equations,F1+F3));
the result which I'm seeking is just a simple [x1+x2,y1+y2,z1+z2], but I got instead: [[x1-x2,x1-y2,x1-z2],[y1-x2,y1-y2,y1-z2],[z1-x2,z1-y2,z1-z2]]
any suggestions?
OK, that is pretty puzzling, although I see now what's going on.
subst is serial (one by one) substitution, so subst([F1 = ..., F2 = ...], ...) is equivalent to subst(F2 = ..., subst(F1 = ..., ...)). That is, substitute for F1 first and then substitute F2 into the result of that.
However the result of subst(F1 = [x1, y1, z1], F1 - F2) is [x1 - F2, y1 - F2, z1 - F2]. You can see now what's going to happen if you substitute F2 into that -- you'll get the messy nested list result.
I think if you try psubst (parallel substitution) you'll get the expected result.
(%i2) forces:[
F1=[x1,y1,z1],
F2=[x2,y2,z2]
];
(%o2) [F1 = [x1, y1, z1], F2 = [x2, y2, z2]]
(%i3) equations:[F3=-F2];
(%o3) [F3 = - F2]
(%i4) subst(equations, F1 + F3);
(%o4) F1 - F2
(%i5) psubst (forces, %o4);
(%o5) [x1 - x2, y1 - y2, z1 - z2]
(%i6) psubst(forces, subst(equations, F1 + F3));
(%o6) [x1 - x2, y1 - y2, z1 - z2]

Maxima: How to replace the variables to simplify the equation?

(%i1) r: sqrt(x^2+y^2+z^2);
(r) sqrt(z^2+y^2+x^2)
(%i2) dx: diff(r,x);
(dx) x/sqrt(z^2+y^2+x^2)
I just show a simple code because my code is long and complex.
I want to simplify dx and get the result is x/r not x/sqrt(z^2+y^2+x^2).
However, I can't find the useful command.
Could somebody help me to solve this problem?
In this specific case, you can use subst, although ratsubst is probably useful in a greater number of cases.
(%i1) linel:65;
(%o1) 65
(%i2) r: sqrt(x^2+y^2+z^2);
2 2 2
(%o2) sqrt(z + y + x )
(%i3) diff (r, x);
x
(%o3) ------------------
2 2 2
sqrt(z + y + x )
(%i5) subst (r = 'r, %o3);
x
(%o5) -
r
(%i6) ratsubst ('r, r, %o3);
x
(%o6) -
r
Note that the single quote mark prevents evaluation, so that 'r is the symbol r instead of the value of r (namely sqrt(x^2 + y^2 + z^2)).

Maxima: Simplify expressions containing minimum

I am trying to use Maxima to simplify mathematical expressions involving min(a, b). Say I have defined
z = min(x1, x2) and d = abs(x1 - x2), then the identities x1 * x2 = z*(z+d) and x1 + x2 = 2*z + d follow.
For example, take the following expression:
(2*z^3+(−3*x2−3*x1)*z^2+6*x1*x2*z)/6
If I manually apply the above identities, I can simplify it to
z^3 / 3 + (z^2 * d) / 2
In Maxima, naively trying
subst(min(x1, x2), v, ((6*v*x1−3*v^2)*x2−3*v^2*x1+2*v^3)/6), ratsimp
Produces a long expression.
How can I make Maxima find the occurrences of x1 * x2 and x1 + x2 buried deep inside the expression? I have tried various forms of tellsimp, let and letsimp, for example:
let(x1*x2, z * (z+d))
or
let(K * x1*x2, K * z * (z + d), K, integer)
or
matchdeclare(R, true)
let(R * x1*x2 * z, R * z * (z+d))
How can I make Maxima produce the nice short expression that I can manually arrive at? I need to work with much larger expressions.
May be this is helpful,
load("lrats");
lratsubst([x1*x2=z*(z+d),x1+x2=2*z+d],
(2*z^3+(−3*x2−3*x1)*z^2+6*x1*x2*z)/6)
(2*z^3+3*d*z^2)/6
Also if you want to test your identities, you could do
z(x1,x2):=min(x1,x2)$
d(x1,x2):=abs(x1-x2)$
Now put numerical values say, z(2,3)*(z(2,3)+d(2,3))=6. Apparently these don't help in simplifying your expression.

Resources