Exemplo n.º 1
0
def visualize(cnt, model, rundir, idxs, str):
    """
    Visualize a set of examples using t-SNE.
    """
    from vocabulary import wordmap, wordform
    PERPLEXITY = 30

    idxs = [id % model.parameters.embeddings.shape[0] for id in idxs]
    x = model.parameters.embeddings[idxs]
    print x.shape
    #titles = [`wordmap().str(id)` for id in idxs]
    titles = [wordform(id) for id in idxs]

    import os.path
    filename = os.path.join(
        rundir, "embeddings.model-%s.-%s-%d.png" % (model.modelname, str, cnt))
    try:
        from textSNE.calc_tsne import tsne
        #       from textSNE.tsne import tsne
        out = tsne(x, perplexity=PERPLEXITY)
        from textSNE.render import render
        render([(title, point[0], point[1])
                for title, point in zip(titles, out)], filename)
    except IOError:
        logging.info("ERROR visualizing", filename, ". Continuing...")
def visualize(embeddings, idxs, name, PERPLEXITY=30):
    idxs = [w % embeddings.shape[0] for w in idxs]
    titles = [wordform(w) for w in idxs]
    import os.path
    filename = HYPERPARAMETERS["INITIAL_EMBEDDINGS"] + ".visualize-%s.png" % name
    try:
        from textSNE.calc_tsne import tsne
#       from textSNE.tsne import tsne
        out = tsne(embeddings[idxs], perplexity=PERPLEXITY)
        from textSNE.render import render
        render([(title, point[0], point[1]) for title, point in zip(titles, out)], filename)
    except IOError:
        logging.info("ERROR visualizing", filename, ". Continuing...")
Exemplo n.º 3
0
def visualize(embeddings, idxs, name, PERPLEXITY=30):
    idxs = [w % embeddings.shape[0] for w in idxs]
    titles = [wordform(w) for w in idxs]
    import os.path
    filename = HYPERPARAMETERS[
        "INITIAL_EMBEDDINGS"] + ".visualize-%s.png" % name
    try:
        from textSNE.calc_tsne import tsne
        #       from textSNE.tsne import tsne
        out = tsne(embeddings[idxs], perplexity=PERPLEXITY)
        from textSNE.render import render
        render([(title, point[0], point[1])
                for title, point in zip(titles, out)], filename)
    except IOError:
        logging.info("ERROR visualizing", filename, ". Continuing...")
def visualize(cnt, embeddings, rundir, idxs, str):
    """
    Visualize a set of examples using t-SNE.
    """
    from vocabulary import wordmap
    PERPLEXITY=30

    x = embeddings[idxs]
    print x.shape
    titles = [wordmap.str(id) for id in idxs]

    import os.path
    filename = os.path.join(rundir, "embeddings-%s-%d.png" % (str, cnt))
    try:
        from textSNE.calc_tsne import tsne
#       from textSNE.tsne import tsne
        out = tsne(x, perplexity=PERPLEXITY)
        from textSNE.render import render
        render([(title, point[0], point[1]) for title, point in zip(titles, out)], filename)
    except IOError:
        logging.info("ERROR visualizing", filename, ". Continuing...")
Exemplo n.º 5
0
def visualize(cnt, model, rundir, idxs, str):
    """
    Visualize a set of examples using t-SNE.
    """
    from vocabulary import wordmap, wordform
    PERPLEXITY=30

    idxs = [id % model.parameters.embeddings.shape[0] for id in idxs]
    x = model.parameters.embeddings[idxs]
    print x.shape
    #titles = [`wordmap().str(id)` for id in idxs]
    titles = [wordform(id) for id in idxs]

    import os.path
    filename = os.path.join(rundir, "embeddings.model-%s.-%s-%d.png" % (model.modelname, str, cnt))
    try:
        from textSNE.calc_tsne import tsne
#       from textSNE.tsne import tsne
        out = tsne(x, perplexity=PERPLEXITY)
        from textSNE.render import render
        render([(title, point[0], point[1]) for title, point in zip(titles, out)], filename)
    except IOError:
        logging.info("ERROR visualizing", filename, ". Continuing...")