@staticmethod<EOL><INDENT>def init_weights(model):<DEDENT>
if (model.W ** <NUM_LIT:2>).sum() != <NUM_LIT:0.0>:<EOL><INDENT>return<EOL><DEDENT>ops = model.ops<EOL>xp = ops.xp<EOL>ops.normal_init(model.W, model.nF * model.nI, inplace=True)<EOL>ids = ops.allocate((<NUM_LIT>, model.nF), dtype="<STR_LIT:f>")<EOL>ids += xp.random.uniform(<NUM_LIT:0>, <NUM_LIT:1000>, ids.shape)<EOL>ids = ops.asarray(ids, dtype="<STR_LIT:i>")<EOL>tokvecs = ops.allocate((<NUM_LIT>, model.nI), dtype="<STR_LIT:f>")<EOL>tokvecs += xp.random.normal(loc=<NUM_LIT:0.0>, scale=<NUM_LIT:1.0>, size=tokvecs.size).reshape(<EOL>tokvecs.shape<EOL>)<EOL>def predict(ids, tokvecs):<EOL><INDENT>hiddens = model(tokvecs[:-<NUM_LIT:1>])  <EOL>vectors = model.ops.allocate((ids.shape[<NUM_LIT:0>], model.nO * model.nP), dtype="<STR_LIT:f>")<EOL>hiddens = hiddens.reshape(<EOL>(hiddens.shape[<NUM_LIT:0>] * model.nF, model.nO * model.nP)<EOL>)<EOL>model.ops.scatter_add(vectors, ids.flatten(), hiddens)<EOL>vectors = vectors.reshape((vectors.shape[<NUM_LIT:0>], model.nO, model.nP))<EOL>vectors += model.b<EOL>vectors = model.ops.asarray(vectors)<EOL>if model.nP >= <NUM_LIT:2>:<EOL><INDENT>return model.ops.maxout(vectors)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return vectors * (vectors >= <NUM_LIT:0>)<EOL><DEDENT><DEDENT>tol_var = <NUM_LIT><EOL>tol_mean = <NUM_LIT><EOL>t_max = <NUM_LIT:10><EOL>t_i = <NUM_LIT:0><EOL>for t_i in range(t_max):<EOL><INDENT>acts1 = predict(ids, tokvecs)<EOL>var = model.ops.xp.var(acts1)<EOL>mean = model.ops.xp.mean(acts1)<EOL>if abs(var - <NUM_LIT:1.0>) >= tol_var:<EOL><INDENT>model.W /= model.ops.xp.sqrt(var)<EOL><DEDENT>elif abs(mean) >= tol_mean:<EOL><INDENT>model.b -= mean<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>
This is like the 'layer sequential unit variance', but instead
        of taking the actual inputs, we randomly generate whitened data.

        Why's this all so complicated? We have a huge number of inputs,
        and the maxout unit makes guessing the dynamics tricky. Instead
        we set the maxout weights to values that empirically result in
        whitened outputs given whitened inputs.