Optimization for the autoRec algorithm In its original paper, autoRec proposes the following algorithm:
$min_{\theta} \sum_{i = 1}^{n} \|r^{i} - h(r^{i}, \theta)\|^2_{\mathcal{O}} + \frac{\lambda}{2} (\|W\|_{F}^2 + \|V\|_{F}^{2})$
where $\|\cdot\|^2_{\mathcal{O}}$ means that we only consider the contribution of observed ratings, and $r^{(i)}$ is the user's rating on the $ith$ item. It is not clear to me what $\|\cdot\|_{\mathcal{O}}$ really means. Looking at how it is implemented here. The final output goes through the procedure pred * np.sign(input), but I am still confused as to what is the reason for doing this.
 A: pred * np.sign(input) is taken to be the output of the decoder during training. This way, we get only the estimate of the ratings (inputs) that were observed, assigning $0$ to the outputs that correspond to the unobserved ratings.
This works because the inputs related to unobserved ratings are $0$ valued $\rightarrow$ np.sign(unobserved_input)=np.sign(0)=0 as the numpy.sign documentation explains.
But why is this done?
This is done in order to update the weights of the decoder through backprop (ignoring regularization) only if the related input is an observed rating ($\neq 0$). To see this, we can have a look at how the sum of squares, $C$, would look like if we took into account both the observed and unobserved ratings:
$$C=\sum_{i = 1}^{n} \|r^{i} - h(r^{i}, \theta)\|^2$$
This means that, through backprop, each weight $w_k^i$ that connects a neuron $k$ of the hidden layer to a neuron $i$ of the output layer (which gives the prediction $h(r^{i}, \theta)$), would be updated with a quantity proportional to:
$$\frac{\partial C}{\partial w^i_k}= \frac{\partial C}{\partial h^i}\frac{\partial h^i}{\partial w^i_k} = -2(r^i-h(r^{i}, \theta))\,\,\frac{\partial h^i}{\partial w^i_k}\,\,\,\,\,\,\,\,\propto \,\,\,\,\,\,\,\, (r^i-h(r^{i}, \theta))$$
In general, the rating predictions for unobserved ratings are $\neq0$, but if we impose $h(r^{i}, \theta)=0$ for the unobserved ratings ($r^i=0$) then we can see that we would get:
$$\frac{\partial C}{\partial w^i_k} \propto (r^i-h(r^{i}, \theta))=(r^i-0)= r^i=0 \,\,\,\,\,\,\Rightarrow\,\,\,\,\,\, \frac{\partial C}{\partial w^i_k}=0$$
So the gradients associated with the unobserved ratings would be masked out. Now we understand why pred * np.sign(input) achieves this.
So to sum up, pred * np.sign(input) is used to transform:
$$\sum_{i = 1}^{n} \|r^{i} - h(r^{i}, \theta)\|^2 \,\,\,\,\text{ into }\,\,\,\, \sum_{i = 1}^{n} \|r^{i} - h(r^{i}, \theta)\|^2_{\mathcal{O}}$$
Where $\|\cdot\|^2_{\mathcal{O}}$ is used to remark that only the observed ratings are used in the learning process with backprop as we have seen above.

Edit regarding the comments
Although it's not directly related with the cost function, it may be worthy remarking that the weights represented in the paper by $V$ will also be masked out during backprop if they are related to unobserved inputs.
This is because the update on a weight $v_i^k$ that connects a input neuron $i$ with a hidden layer neuron $k$ is given by a quantity proportional to:
$$\frac{\partial C}{\partial v_i^k} = \delta^k\,r^i \propto r^i$$
Hence, if we have an unobserved input ($r^i=0$) then all the weights that go out from that neuron won't be updated. This also happens to the biases as their update is also proportional to $r^i$.
Finally, in order to help with the notation used in this answer, here it is an image of the network taken from the article AutoRec:

A: Hi: It's been a while since I looked at recommender systems but that term is just summing the differences between the actual ratings in column $i$ of the  ratings matrix and  the predicted ratings in column $i$ of the predicted matrix.
It then does this for each column of the ratings matrix. So, it's a measure of how well the matrix is being mimiced by the algorithm (which is generating a matrix as similar as possible to the original matrix but also predicting the zero elements of the original matrix).
So, $h(r^{i},\theta)$ takes the column $i$ of the matrix and a parameter vector $\theta$ and produces a new rating for each element in the column. That new rating gets subtracted from the actual rating and squared in order to calculate an "error sum of squares", if you will. It's like the SSE in OLS and one wants to minimize that along with some other regularization factors. The || || notation is called a norm but in your case, you can think of it as just subtracting two vectors and then squaring the differences and summing them.
