def _update_activations(self, activations, idx_iter):
        """
        Actually computes the activations for all indices in idx_iters.

        This method computes the values for a layer by computing a linear
        combination of the neighboring layers (dictated by the weight matrices),
        applying the pre-activation corruption, and then applying the layer's
        activation function.

        Parameters
        ----------
        activations : list of tensor_likes
            The activations to update (could be self.activations). Updates
            in-place.
        idx_iter : iterable
            An iterable of indices into self.activations. The indexes
            indicate which layers should be updated.
            Must be able to iterate over idx_iter multiple times.
        """
        from_above = lambda i: ((self.aes[i].visbias if self._bias_switch else 0) +
                                T.dot(activations[i + 1],
                                      self.aes[i].w_prime))

        from_below = lambda i: ((self.aes[i - 1].hidbias if self._bias_switch else 0) +
                                T.dot(activations[i - 1],
                                     self.aes[i - 1].weights))

        for i in idx_iter:
            # first compute the hidden activation
            if i == 0:
                activations[i] = from_above(i)
            elif i == len(activations) - 1:
                activations[i] = from_below(i)
            else:
                activations[i] = from_below(i) + from_above(i)

        self.apply_preact_corruption(activations, idx_iter)

        for i in idx_iter:
            # Using the activation function from lower autoencoder
            act_func = None
            if i == 0:
                act_func = self.aes[0].act_dec
            else:
                act_func = self.aes[i - 1].act_enc

            # ACTIVATION
            # None implies linear
            if act_func is not None:
                activations[i] = act_func(activations[i])