Esempio n. 1
0
    def plot_w1(self, annotate=False, highlight_syms=[], iter_num=None):
        plt.clf()
        configs = self.configs
        if iter_num is not None:
            fname_tag = 'iter_%d' % iter_num
        else:
            fname_tag = ''

        from plot_utilities import plot_vec
        # print self.W1.value.shape, len(self.data.syms)
        assert self.W1.value.shape[0] == len(self.data.syms)
        plot_vec(self.W1.value, self.data.syms, configs,
                 highlight_syms=highlight_syms,
                 doPCA=configs['do_pca'],
                 with_annotations=annotate,
                 fname_tag=fname_tag,
                 save=True)
def get_proxy_model():
    fname = None
    print fname
    assert fname is not None, "Error: no model to retrieve in the time being"
    with open(fname, "rb") as p:
        w1 = pickle.load(p)
        syms = pickle.load(p)
        model_loss = pickle.load(p)
        model_weights = pickle.load(p)
        # configs_reloaded = pickle.load(p)

    COMMON_TONE_CIRCLE = ["I", "iii", "V", "viio6", "ii", "IV", "vi", "I"]
    circle_name = COMMON_TONE_CIRCLE
    song_dict = make_song_dict(circle_name)

    configs_dummy = get_configs()
    fname, ax, vecs = plot_vec(w1, syms, configs_dummy, save=True, doPCA=True, return_ax=True)
    add_arrow_annotation(syms, vecs, song_dict, ax, False)
    plt.savefig("w1-%s.pdf" % Configs.get_timestamp())

    model = WrappeSkipGram(w1, syms)
    return model