GithubHelp home page GithubHelp logo

Comments (4)

simontomaskarlsson avatar simontomaskarlsson commented on August 15, 2024

Hi @MrtnStnwk,

Thank you for your find, I will update the model right away.

from cyclegan-keras.

MrtnStnwk avatar MrtnStnwk commented on August 15, 2024

There seems to be another (minor) issue here. If the number of samples is not dividable by the batch_size, it jams after an epoch. (e.g. following: batch size 4, no samples 6287).

Traceback (most recent call last):
  File "model.py", line 924, in <module>
    GAN = CycleGAN()
  File "model.py", line 243, in __init__
    self.train(epochs=self.epochs, batch_size=self.batch_size, save_interval=self.save_interval)
  File "model.py", line 608, in train
    run_training_iteration(loop_index, epoch_iterations)
  File "model.py", line 407, in run_training_iteration
    DB_loss_real = self.D_B.train_on_batch(x=real_images_B, y=ones)
  File "/home/m.steenwijk/miniconda2/lib/python2.7/site-packages/keras/engine/training.py", line 1211, in train_on_batch
    class_weight=class_weight)
  File "/home/m.steenwijk/miniconda2/lib/python2.7/site-packages/keras/engine/training.py", line 804, in _standardize_user_data
    check_array_length_consistency(x, y, sample_weights)
  File "/home/m.steenwijk/miniconda2/lib/python2.7/site-packages/keras/engine/training_utils.py", line 237, in check_array_length_consistency
    'and ' + str(list(set_y)[0]) + ' target samples.')
ValueError: Input arrays should have the same number of samples as target arrays. Found 3 input samples and 4 target samples.

Line numbers may be a little different because I did some modifications.

I suggest the max number of samples should be dividable by the batch size as a fix.

from cyclegan-keras.

MrtnStnwk avatar MrtnStnwk commented on August 15, 2024

Sorry, I catched another bug (which is only relevant when supervised learning is used).

In load_data it is better to have os.listdir(trainA_path) (and testA, trainB, testB) sorted, because the listdir output is not neccessarily sorted. (output of listdir is dependent on how it is stored in de filesystem).

Solution is to use
trainA_image_names = sorted(os.listdir(trainA_path))

from cyclegan-keras.

simontomaskarlsson avatar simontomaskarlsson commented on August 15, 2024

Hi @MrtnStnwk,

Seemed to have missed your last post. Great that you are commenting the errors, thank you.
I remember working on the error with number of samples needing to be dividable by the batch size but evidentially it is still a problem in this model. I will add a comment on this for now.

Regarding the sorting error you have found you can create a pull request if you want to, otherwise I will update it myself.

from cyclegan-keras.

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.