Coder Social home page Coder Social logo

Comments (8)

LongHuW avatar LongHuW commented on July 24, 2024 2

我这边是因为labels出现了三维array这种数据,所以我加了一个步骤,将其降维成一维就好了

def decode_text(labels, vocabs, end_token = '</s>'):
    results = []
    if isinstance(labels, list) == False and labels.ndim>1:
        labels_one = labels.reshape(-1).astype(int)
        for idx in labels_one:
            word = vocabs[idx]
            if word == end_token:
                return ' '.join(results)
            results.append(word)
        return ' '.join(results)

    for idx in labels:
        word = vocabs[idx]
        if word == end_token:
            return ' '.join(results)
        results.append(word)
    return ' '.join(results)

from seq2seq-couplet.

xiaoshuai1 avatar xiaoshuai1 commented on July 24, 2024

同问

from seq2seq-couplet.

zhoujinyang1996 avatar zhoujinyang1996 commented on July 24, 2024

from seq2seq-couplet.

Lijiaxing-lx avatar Lijiaxing-lx commented on July 24, 2024

from seq2seq-couplet.

Drizzlenum avatar Drizzlenum commented on July 24, 2024

请问跑通了吗

from seq2seq-couplet.

cui-z avatar cui-z commented on July 24, 2024

word = vocabs[idx] 修改为
word = np.array(vocabs)[idx]

from seq2seq-couplet.

DaemonicCao avatar DaemonicCao commented on July 24, 2024

from seq2seq-couplet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.