Skip to content

Keep Parents Issue #49

Closed
Closed

Description

@edgardohb

Hello, first of all I would like to say you did an excellent job with the pygad project.

Secondly, I would like to address an issue I am having with the keep_parents parameter. I was running an algorithm yesterday and it was working fine, but some changes were made to the code apparently, and now everytime I assign a value to that parameter an error pops up. It is because some part of the code related to it has a variable as a tuple, but the atribute .shape is called upon, which is only supported for numpy arrays.

The error is the following:
AttributeError: 'tuple' object has no attribute 'shape'

And it happens on the line 1202 of the pygad.py code.

1200 elif (self.keep_parents > 0): 1201 parents_to_keep = self.steady_state_selection(self.last_generation_fitness, num_parents=self.keep_parents) -> 1202 self.population[0:parents_to_keep.shape[0], :] = parents_to_keep 1203 self.population[parents_to_keep.shape[0]:, :] = self.last_generation_offspring_mutation 1204

Is there a different way to implement this parameter now? Or if there is not is there a posibility that you would mind fixing the code?

Thanks for your time and work on the pygad project.

Activity

  1. added a commit that references this issue on Jun 18, 2021
  2. self-assigned this
    on Jun 18, 2021
  3. added
    bug
    on Jun 18, 2021
  4. ahmedfgad commented on Jun 18, 2021

    @ahmedfgad
    Owner

    Hello,

    Thanks for opening this issue. It is solved now. The project is updated.

    PyGAD 2.15.1 will be released shortly to address the issue.

    Please feel free to get in touch if any issues arise.

  5. added a commit that references this issue on Jun 18, 2021
  6. ahmedfgad commented on Jun 18, 2021

    @ahmedfgad
    Owner

    PyGAD 2.15.1 is released that solves the issue.

    Feel free to upgrade to the latest version:

    pip3 install --upgrade pygad

    Thank you!

  7. edgardohb commented on Jun 18, 2021

    @edgardohb
    Author
  8. ahmedfgad commented on Jun 18, 2021

    @ahmedfgad
    Owner

    @edgardohb
    Yes use this command to upgrade to latest version:

    pip install --upgrade pygad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions