GithubHelp home page GithubHelp logo

Comments (9)

HernandezEduin avatar HernandezEduin commented on May 28, 2024 1

I had the same issue. It turns out to be an issue with my dataset.

To overcome this, I modified the following in utils/text_process.py:

def tokens_to_tensor(tokens, dictionary):
    tensor = []
    for sent in tokens:
        sent_ten = []
        i = - 1
        for i, word in enumerate(sent):
            if word == cfg.padding_token:
                break
            sent_ten.append(int(dictionary[str(word)]))
        
        sent_ten = sent_ten + (cfg.max_seq_len + 1 - i)*[cfg.padding_idx]
        
        tensor.append(sent_ten[:cfg.max_seq_len])
    return torch.LongTensor(tensor)

Tensor was a list with list of dynamic size. This ensures all list are of the same size, even if the list is empty.

from textgan-pytorch.

williamSYSU avatar williamSYSU commented on May 28, 2024

Do you put the comment.txt file into the dataset directory? The self.train_data needs to load the dataset file you specified in the config.py file (parameter dataset), but it seems there is no file named dataset/comment.txt.

from textgan-pytorch.

mnavaidd avatar mnavaidd commented on May 28, 2024

I have received same error, when I changed the dataset. Even I have placed dataset file in dataset folder.

raceback (most recent call last):
  File "main.py", line 167, in <module>
    inst = instruction_dict[cfg.run_model](opt)
  File "TextGAN-PyTorch/instructor/real_data/seqgan_instructor.py", line 23, in __init__
    super(SeqGANInstructor, self).__init__(opt)
  File "TextGAN-PyTorch/instructor/real_data/instructor.py", line 72, in __init__
    self.ppl = PPL(self.train_data, self.test_data, n_gram=5, if_use=cfg.use_ppl)
AttributeError: 'SeqGANInstructor' object has no attribute 'train_data'

from textgan-pytorch.

viko-3 avatar viko-3 commented on May 28, 2024

I have received same error, when I changed the dataset. Even I have placed dataset file in dataset folder.

raceback (most recent call last):
  File "main.py", line 167, in <module>
    inst = instruction_dict[cfg.run_model](opt)
  File "TextGAN-PyTorch/instructor/real_data/seqgan_instructor.py", line 23, in __init__
    super(SeqGANInstructor, self).__init__(opt)
  File "TextGAN-PyTorch/instructor/real_data/instructor.py", line 72, in __init__
    self.ppl = PPL(self.train_data, self.test_data, n_gram=5, if_use=cfg.use_ppl)
AttributeError: 'SeqGANInstructor' object has no attribute 'train_data'

and have you sloved this problem now?I have the same problem

from textgan-pytorch.

viko-3 avatar viko-3 commented on May 28, 2024

I have received same error, when I changed the dataset. Even I have placed dataset file in dataset folder.

raceback (most recent call last):
  File "main.py", line 167, in <module>
    inst = instruction_dict[cfg.run_model](opt)
  File "TextGAN-PyTorch/instructor/real_data/seqgan_instructor.py", line 23, in __init__
    super(SeqGANInstructor, self).__init__(opt)
  File "TextGAN-PyTorch/instructor/real_data/instructor.py", line 72, in __init__
    self.ppl = PPL(self.train_data, self.test_data, n_gram=5, if_use=cfg.use_ppl)
AttributeError: 'SeqGANInstructor' object has no attribute 'train_data'

and have you sloved this problem now?I have the same problem

I solve it ,maybe the dataset has some problem.

from textgan-pytorch.

julfr avatar julfr commented on May 28, 2024

I had the same issue. It turns out to be an issue with my dataset.

To overcome this, I modified the following in utils/text_process.py:

def tokens_to_tensor(tokens, dictionary):
    tensor = []
    for sent in tokens:
        sent_ten = []
        i = - 1
        for i, word in enumerate(sent):
            if word == cfg.padding_token:
                break
            sent_ten.append(int(dictionary[str(word)]))
        
        sent_ten = sent_ten + (cfg.max_seq_len + 1 - i)*[cfg.padding_idx]
        
        tensor.append(sent_ten[:cfg.max_seq_len])
    return torch.LongTensor(tensor)

Tensor was a list with list of dynamic size. This ensures all list are of the same size, even if the list is empty.

Hi, I have the same problem with catgan.py. I modified text_process.py as you suggested, but then another error appears:

File "/home/sc.uni-leipzig.de/ie870xetu/TextGAN-PyTorch/instructor/real_data/catgan_instructor.py", line 63, in __init__
    self.all_train_data = CatGenDataIter(self.train_samples_list)
`AttributeError: 'CatGANInstructor' object has no attribute 'train_samples_list'`

@HernandezEduin

from textgan-pytorch.

julfr avatar julfr commented on May 28, 2024

has some problem.

How did you solve your problem?

from textgan-pytorch.

julfr avatar julfr commented on May 28, 2024

has some problem.

How did you solve your problem?
@Cyy1216

from textgan-pytorch.

keerthan-381 avatar keerthan-381 commented on May 28, 2024

I am also getting the same error.
AttributeError: 'CatGANInstructor' object has no attribute 'train_samples_list'
How to resolve it ?

from textgan-pytorch.

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.