Exemple #1
0
def plot_relu_layer(input):
    num = 1
    for channel in range(input.shape[-1]):
        result = input[:, :, channel]
        result = result.reshape(input.shape[0], input.shape[1])
        ax = subplot(5, 2, num, frame_on=False)
        ax.xaxis.set_major_locator(NullLocator())  # remove ticks
        ax.yaxis.set_major_locator(NullLocator())
        num += 1
        plt.imshow(result, origin='upper')
        plt.title('channel #' + str(channel))
    plt.tight_layout()
    plt.savefig('relu_activations.png')
                ]),
        color="green",
        lw=1,
        linestyle=lss[i],
        label=None if i else "env. friendly individuals")
ax12.plot(t[3:],
          100 * mean([
              array(traj["SocialSystem.has_emissions_tax"][s][3:] * 1)
              for s in social_systems
          ],
                     axis=0),
          color="cyan",
          lw=2,
          label="regions w/ emissions tax")
ax12.set_ylim(-5, 105)
ax12.yaxis.set_major_locator(NullLocator())
ax12.legend(loc=7)

# metabolic
for i, s in enumerate(social_systems):
    Es = array(traj["SocialSystem.secondary_energy_flow"][s][3:])
    ax22.plot(t[3:],
              100 * array(traj["SocialSystem.biomass_input_flow"][s][3:]) *
              40e9 / Es,
              color="green",
              lw=lws,
              alpha=al,
              linestyle=lss[i],
              label=None if i else "biomass")
    ax22.plot(t[3:],
              100 * array(traj["SocialSystem.fossil_fuel_input_flow"][s][3:]) *
Exemple #3
0
                 color=(0, 0.25, 0))
        else:
            text(1.8 * n - 2,
                 0.14 * t_numpy - 6e-6,
                 label_numpy,
                 horizontalalignment='right',
                 size=11,
                 color=(0, 0.25, 0))

    from matplotlib.text import FontProperties

    for n, t_python, t_numpy, label_python, label_numpy in \
            zip(sizes, time_python, time_numpy, labels_python, labels_numpy)[:-1]:
        make_mark(n, t_python, t_numpy, label_python, label_numpy)

    ax.xaxis.minor.locator = NullLocator()
    yticks((1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1),
           (u'10µs', u'100µs', u'1ms', u'10ms', u'100ms', u'1s'))
    ax.yaxis.tick_right()
    ax.yaxis.grid(alpha=0.4)

    for t in ax.xaxis.majorTicks:
        t.tick2line.set_visible(False)

    legend(loc='upper left', numpoints=1, prop=FontProperties(size=12))
    text(2, 1e-6, 'n')

    ylabel(u"Temps d'éxécution")

    savefig('timings.eps')
Exemple #4
0
A = imread('../data/shakira.png')  # load an image
A = mean(A, 2)  # to get a 2-D array
full_pc = size(A, axis=1)  # numbers of all the principal components
i = 1
dist = []
for numpc in range(0, full_pc + 10, 10):  # 0 10 20 ... full_pc
    coeff, score, latent = princomp(A, numpc)
    Ar = dot(coeff, score).T + mean(A, axis=0)  # image reconstruction
    # difference in Frobenius norm
    dist.append(linalg.norm(A - Ar, 'fro'))
    # showing the pics reconstructed with less than 50 PCs
    print "trying %s principal components with a distance of: %f" % (numpc,
                                                                     dist[-1])
    if numpc <= 50:
        if numpc == 50:
            imsave(fname='../data/' + str(numpc) + '.jpg', arr=Ar)
        ax = subplot(2, 3, i, frame_on=False)
        ax.xaxis.set_major_locator(NullLocator())  # remove ticks
        ax.yaxis.set_major_locator(NullLocator())
        i += 1
        imshow(Ar)
        title('PCs # ' + str(numpc))
        gray()

figure()
imshow(A)
title('numpc FULL')
gray()
show()
Exemple #5
0
                   10):  # 0 10 20 ... full_pc + 10 sayısı içinde döngü
    coeff, score, latent = princomp(A, numpc)

    Ar = dot(coeff, score).T + mean(A, axis=0)  # imajı tekrar yapılandırma

    # Frobenius normdaki farklılık
    dist.append(linalg.norm(A - Ar, 'fro'))

    # temel bileşenlerle yeniden yapılandırılan imajları göster

    # 50'den az olan temel bileşenler kullanılmıştır

    if numpc <= 50:
        ax = subplot(2, 3, i, frame_on=False)

        ax.xaxis.set_major_locator(NullLocator())
        ax.yaxis.set_major_locator(NullLocator())

        i += 1

        plt.imshow(Ar)
        title('PCs # ' + str(numpc))
        gray()

figure()
imshow(A)
title('numpc FULL')
gray()
show()

from pylab import plot, axis