def draw_weights(W=None, second=<NUM_LIT:10>, saveable=True, shape=None, name='<STR_LIT>', fig_idx=<NUM_LIT>):
if shape is None:<EOL><INDENT>shape = [<NUM_LIT>, <NUM_LIT>]<EOL><DEDENT>import matplotlib.pyplot as plt<EOL>if saveable is False:<EOL><INDENT>plt.ion()<EOL><DEDENT>fig = plt.figure(fig_idx)  <EOL>n_units = W.shape[<NUM_LIT:1>]<EOL>num_r = int(np.sqrt(n_units))  <EOL>num_c = int(np.ceil(n_units / num_r))<EOL>count = int(<NUM_LIT:1>)<EOL>for _row in range(<NUM_LIT:1>, num_r + <NUM_LIT:1>):<EOL><INDENT>for _col in range(<NUM_LIT:1>, num_c + <NUM_LIT:1>):<EOL><INDENT>if count > n_units:<EOL><INDENT>break<EOL><DEDENT>fig.add_subplot(num_r, num_c, count)<EOL>feature = W[:, count - <NUM_LIT:1>] / np.sqrt((W[:, count - <NUM_LIT:1>]**<NUM_LIT:2>).sum())<EOL>plt.imshow(<EOL>np.reshape(feature, (shape[<NUM_LIT:0>], shape[<NUM_LIT:1>])), cmap='<STR_LIT>', interpolation="<STR_LIT>"<EOL>)  <EOL>plt.gca().xaxis.set_major_locator(plt.NullLocator())  <EOL>plt.gca().yaxis.set_major_locator(plt.NullLocator())<EOL>count = count + <NUM_LIT:1><EOL><DEDENT><DEDENT>if saveable:<EOL><INDENT>plt.savefig(name + '<STR_LIT>', format='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>plt.draw()<EOL>plt.pause(second)<EOL><DEDENT>
Visualize every columns of the weight matrix to a group of Greyscale img.

    Parameters
    ----------
    W : numpy.array
        The weight matrix
    second : int
        The display second(s) for the image(s), if saveable is False.
    saveable : boolean
        Save or plot the figure.
    shape : a list with 2 int or None
        The shape of feature image, MNIST is [28, 80].
    name : a string
        A name to save the image, if saveable is True.
    fig_idx : int
        matplotlib figure index.

    Examples
    --------
    >>> tl.visualize.draw_weights(network.all_params[0].eval(), second=10, saveable=True, name='weight_of_1st_layer', fig_idx=2012)