Code Monkey home page Code Monkey logo

Comments (11)

MerouaneB avatar MerouaneB commented on June 27, 2024 3

I used the versions fixed before (python 3.4 / keras 2.1.4 / Tensorflow 1.5.0).
I substituted the next function with the 2 functions above.
In the trainModel function in cnn.py, "decay" is not recognized as argument of the compile function despite the fact that is a learning rate for the optimizer used to compile the model. So i written it like this
optimizer=optimizers.Adam(decay=1e-5)
model.compile(loss=[utils.hard_mining_mse(model.k_mse),
utils.hard_mining_entropy(model.k_entropy)],
optimizer=optimizer, loss_weights=[model.alpha, model.beta])

from rpg_public_dronet.

antonilo avatar antonilo commented on June 27, 2024 2

@MerouaneB thanks for your feedback. I will soon update the repo to adjust for the new changes in Keras.

from rpg_public_dronet.

antonilo avatar antonilo commented on June 27, 2024 1

I guess your problem is that you are using python 2.X and not python 3.X.
try to substitute the next function in the DroneDirectoryIterator with these 2 functions:

  def next(self):                                                                                                                                                                                                                    
        with self.lock:                                                                                                                                                                                                                
            index_array = next(self.index_generator)                                                                                                                                                                                   
        # The transformation of images is not under thread lock                                                                                                                                                                        
        # so it can be done in parallel                                                                                                                                                                                                
        return self._get_batches_of_transformed_samples(index_array) 

  def _get_batches_of_transformed_samples(self, index_array) :
        current_batch_size = index_array.shape[0]                                                                                                                                                                                                                                                                                                                                                                                                              
        # Image transformation is not under thread lock, so it can be done in                                                                                                                                                          
        # parallel                                                                                                                                                                                                                     
        batch_x = np.zeros((current_batch_size,) + self.image_shape,                                                                                                                                                                   
                dtype=K.floatx())                                                                                                                                                                                                      
        batch_steer = np.zeros((current_batch_size, 2,),                                                                                                                                                                               
                dtype=K.floatx())                                                                                                                                                                                                      
        batch_coll = np.zeros((current_batch_size, 2,),                                                                                                                                                                                
                dtype=K.floatx())                                                                                                                                                                                                      
                                                                                                                                                                                                                                       
        grayscale = self.color_mode == 'grayscale'                                                                                                                                                                                     
                                                                                                                                                                                                                                       
        # Build batch of image data                                                                                                                                                                                                    
        for i, j in enumerate(index_array):                                                                                                                                                                                            
            fname = self.filenames[j]                                                                                                                                                                                                  
            x = img_utils.load_img(os.path.join(self.directory, fname),                                                                                                                                                                
                    grayscale=grayscale,                                                                                                                                                                                               
                    crop_size=self.crop_size,                                                                                                                                                                                          
                    target_size=self.target_size)                                                                                                                                                                                      
                                                                                                                                                                                                                                       
            x = self.image_data_generator.random_transform(x)                                                                                                                                                                          
            x = self.image_data_generator.standardize(x)                                                                                                                                                                               
            batch_x[i] = x                                                                                                                                                                                                             
                                                                                                                                                                                                                                       
            # Build batch of steering and collision data                                                                                                                                                                               
            if self.exp_type[index_array[i]] == 1:                                                                                                                                                                                     
                # Steering experiment (t=1)                                                                                                                                                                                            
                batch_steer[i,0] =1.0                                                                                                                                                                                                  
                batch_steer[i,1] = self.ground_truth[index_array[i]]                                                                                                                                                                   
                batch_coll[i] = np.array([1.0, 0.0])                                                                                                                                                                                   
            else:                                                                                                                                                                                                                      
                # Collision experiment (t=0)                                                                                                                                                                                           
                batch_steer[i] = np.array([0.0, 0.0])                                                                                                                                                                                  
                batch_coll[i,0] = 0.0                                                                                                                                                                                                  
                batch_coll[i,1] = self.ground_truth[index_array[i]]                                                                                                                                                                    
                                                                                                                                                                                                                                       
        batch_y = [batch_steer, batch_coll]                                                                                                                                                                                            
        return batch_x, batch_y               

from rpg_public_dronet.

antonilo avatar antonilo commented on June 27, 2024 1

Should be solved in the last commit 02908de.
Thanks for the feedback!

from rpg_public_dronet.

dsxxxk avatar dsxxxk commented on June 27, 2024

Python have to be updated to 3.6.5 when i install keras2.1.4 and tensorflow1.5.0.
However, i have the same exception as yours.
...
I have to read the source code of keras to look for some faults.

from rpg_public_dronet.

MerouaneB avatar MerouaneB commented on June 27, 2024

Hi ! I have the same exception too and i did not resolve it. I am stuck in it for 3 days and i did not find the solution yet. I checked the source code of keras so i found that the generator queue still empty for the "next" function in fit_generator which raises the exception. I think the DroneDirectoryIterator object is not recognized. Do you have any idea ?
Thanks

from rpg_public_dronet.

MerouaneB avatar MerouaneB commented on June 27, 2024

Thanks for your reply,
I tried these 2 functions but the probelm still the same. I found that the next function takes a generator object as un argument and not a DroneDirectoryIterator object . The problem starts before, especially in enqueuer.start which starts threads that have to fill the queue from sequence. Unfortunately it doesn't happen and i don't know why ??
I am shure that it should be a simple solution to this error(keras version...) but until now i'm stuck.
I used all versions of python 2.7/3.5/3.4 with keras 2.1.4/2.0.8 and tensorflow 1.5.0

from rpg_public_dronet.

antonilo avatar antonilo commented on June 27, 2024

@MerouaneB can you paste here the error you get when using the functions I recommended above?

from rpg_public_dronet.

MerouaneB avatar MerouaneB commented on June 27, 2024

Sorry i must have missed something, now i get this error using the 2 functions:

Traceback (most recent call last):
File "cnn.py", line 176, in
main(sys.argv)
File "cnn.py", line 172, in main
_main()
File "cnn.py", line 161, in _main
trainModel(train_generator, val_generator, model, initial_epoch)
File "cnn.py", line 89, in trainModel
initial_epoch=initial_epoch)
File "/usr/local/lib/python3.4/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.4/site-packages/keras/engine/training.py", line 2243, in fit_generator
class_weight=class_weight)
File "/usr/local/lib/python3.4/site-packages/keras/engine/training.py", line 1890, in train_on_batch
outputs = self.train_function(ins)
File "/usr/local/lib/python3.4/site-packages/keras/backend/tensorflow_backend.py", line 2475, in call
**self.session_kwargs)
TypeError: run() got an unexpected keyword argument 'decay'

from rpg_public_dronet.

MerouaneB avatar MerouaneB commented on June 27, 2024

Thanks for everything i solved this error !! Now i can launch the training

from rpg_public_dronet.

jmidwint avatar jmidwint commented on June 27, 2024

@MerouaneB - Can you post the solution that you used to get this to work? the versions of s/w dependencies (python, Keras, Tensorflow ) that you used ? Did you ... substitute the next function in the DroneDirectoryIterator with those 2 functions as posted by the author @antonilo. Thanks!

from rpg_public_dronet.

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.