예제 #1
0
                            distargs=(), loc=0, scale=1, line='45')
            plt.grid()
            fig.savefig('logs/out/{}/real.png'.format(saved_file))
            plt.close()

    if it % 1000 == 0:
        sequences_generator = []
        for _ in range(int(1000 / BATCH_SIZE)):
            sequences_gen = sess.run(fake_data, feed_dict={
                Z: fake_batch[0], fake_seqlen: fake_batch[1]})
            shape_gen = sequences_gen.shape
            sequences_gen = np.reshape(
                sequences_gen, (shape_gen[0], shape_gen[1]))
            if D_DIFF:
                sequences_gen = np.cumsum(sequences_gen, axis=1)
            sequences_gen = sequence_filter(
                sequences_gen, fake_batch[1])  # remove padding tokens
            sequences_generator += sequences_gen

        ts_gen, intensity_gen = get_intensity(sequences_generator, T, n_t)
        deviation = np.linalg.norm(
            intensity_gen - intensity_real) / np.linalg.norm(intensity_real)

        print(
            'Iter: {}; D loss: {:.4}; G_loss: {:.4}; data:{}; deviation: {}'.format(
                it, D_loss_curr, G_loss_curr, DATA, deviation))
        plt.plot(ts_real, intensity_real, label='real')
        plt.plot(ts_gen, intensity_gen, label='generated')
        plt.legend(loc=1)
        plt.xlabel('time')
        plt.ylabel('intensity')
        plt.savefig('logs/out/{}/{}_{}.png'
예제 #2
0
파일: rmtpp.py 프로젝트: zhh0998/pp
            'Iter: {}; Data: {}; D loss: {:.4}; neglik:{}; reg:{} Para:{}; w:{}'
            .format(it, DATA, D_loss_curr, neglike, regular, para_max_,
                    decay_w_))
        if np.max(np.abs(last_value - column_para_)) < 1e-4 and np.abs(
                D_loss_curr -
                last_loss) < 1:  #np.max(np.abs(last_value-column_para_))<1e-2
            stop_indicator = True
        last_value = column_para_
        last_loss = D_loss_curr

    if it % 1000 == 0 and it > 10000:
        sequences_generator = []
        for _ in range(100):
            sequences_gen = sess.run(fake_data)
            sequences_generator.append(sequences_gen)
        sequences_generator = sequence_filter(sequences_generator, None, T)
        ts_gen, intensity_gen = get_intensity(sequences_generator, T, n_t)
        deviation = np.linalg.norm(
            intensity_gen - intensity_real) / np.linalg.norm(intensity_real)

        plt.plot(ts_real, intensity_real, label='real')
        plt.plot(ts_gen, intensity_gen, label='generated')
        plt.legend(loc=1)
        plt.xlabel('time')
        plt.ylabel('intensity')
        plt.savefig('out/{}/{}_{}.png'.format(saved_file,
                                              str(it).zfill(3), deviation),
                    bbox_inches='tight')
        plt.close()

        if not REAL_DATA and DATA != "rmtpp":