rpg_public_dronet icon indicating copy to clipboard operation
rpg_public_dronet copied to clipboard

there is not python3.4 with keras2.1.4 and tensorflow1.0.1 ; so , i install python3.5 with keras2.1.4 and tensorflow1.0.1

Open xiongdemao opened this issue 6 years ago • 11 comments

there is not python3.4 with keras2.1.4 and tensorflow1.0.1 ; so , i install python3.5 with keras2.1.4 and tensorflow1.0.1

@TitanX:~$ conda search tensorflow
Loading channels: done
Name                       Version                   Build  Channel        
tensorflow                 0.10.0rc0           np111py27_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 0.10.0rc0           np111py27_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow                 0.10.0rc0           np111py27_0  defaults       
tensorflow                 0.10.0rc0           np111py34_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 0.10.0rc0           np111py34_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow                 0.10.0rc0           np111py34_0  defaults       
tensorflow                 0.10.0rc0           np111py35_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 0.10.0rc0           np111py35_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow                 0.10.0rc0           np111py35_0  defaults       
tensorflow                 1.0.1               np112py27_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 1.0.1               np112py27_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow                 1.0.1               np112py27_0  defaults       
tensorflow                 1.0.1               np112py35_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 1.0.1               np112py35_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow                 1.0.1               np112py35_0  defaults       
tensorflow                 1.0.1               np112py36_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 1.0.1               np112py36_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
tensorflow                 1.0.1               np112py36_0  defaults       
tensorflow                 1.1.0               np111py27_0  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
tensorflow                 1.1.0               np111py27_0  https://mirrors.ustc.edu.cn/anaconda/pkgs/free
keras                      2.1.2                    py35_0  defaults       
keras                      2.1.2                    py36_0  defaults       
keras                      2.1.3                    py27_0  defaults       
keras                      2.1.3                    py35_0  defaults       
keras                      2.1.3                    py36_0  defaults       
keras                      2.1.4                    py27_0  defaults       
keras                      2.1.4                    py35_0  defaults       
keras                      2.1.4                    py36_0  defaults       
keras                      2.1.5                    py27_0  defaults 

there is not python3.4 with keras2.1.4 and tensorflow1.0.1 ; so , i install python3.5 with keras2.1.4 and tensorflow1.0.1 . Then, happen follow error:

/home/anaconda2/envs/dronet/bin/python -u /home/pytest/dronet/rpg_public_dronet-master1/cnn.py --experiment_rootdir='./model/test_1' --train_dir='/home/datafile/dronet_data/collision_dataset/training' --val_dir='/home/datafile/dronet_data/collision_dataset/validation' --batch_size=16 --epochs=150 --log_rate=25
Using TensorFlow backend.
Found 63169 images belonging to 132 experiments.
Found 1035 images belonging to 3 experiments.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
__________________________________________________________________________________________________
Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            (None, 200, 200, 1)  0                                            
__________________________________________________________________________________________________
conv2d_1 (Conv2D)               (None, 100, 100, 32) 832         input_1[0][0]                    
__________________________________________________________________________________________________
max_pooling2d_1 (MaxPooling2D)  (None, 49, 49, 32)   0           conv2d_1[0][0]                   
__________________________________________________________________________________________________
batch_normalization_1 (BatchNor (None, 49, 49, 32)   128         max_pooling2d_1[0][0]            
__________________________________________________________________________________________________
activation_1 (Activation)       (None, 49, 49, 32)   0           batch_normalization_1[0][0]      
__________________________________________________________________________________________________
conv2d_2 (Conv2D)               (None, 25, 25, 32)   9248        activation_1[0][0]               
__________________________________________________________________________________________________
batch_normalization_2 (BatchNor (None, 25, 25, 32)   128         conv2d_2[0][0]                   
__________________________________________________________________________________________________
activation_2 (Activation)       (None, 25, 25, 32)   0           batch_normalization_2[0][0]      
__________________________________________________________________________________________________
conv2d_4 (Conv2D)               (None, 25, 25, 32)   1056        max_pooling2d_1[0][0]            
__________________________________________________________________________________________________
conv2d_3 (Conv2D)               (None, 25, 25, 32)   9248        activation_2[0][0]               
__________________________________________________________________________________________________
add_1 (Add)                     (None, 25, 25, 32)   0           conv2d_4[0][0]                   
                                                                 conv2d_3[0][0]                   
__________________________________________________________________________________________________
batch_normalization_3 (BatchNor (None, 25, 25, 32)   128         add_1[0][0]                      
__________________________________________________________________________________________________
activation_3 (Activation)       (None, 25, 25, 32)   0           batch_normalization_3[0][0]      
__________________________________________________________________________________________________
conv2d_5 (Conv2D)               (None, 13, 13, 64)   18496       activation_3[0][0]               
__________________________________________________________________________________________________
batch_normalization_4 (BatchNor (None, 13, 13, 64)   256         conv2d_5[0][0]                   
__________________________________________________________________________________________________
activation_4 (Activation)       (None, 13, 13, 64)   0           batch_normalization_4[0][0]      
__________________________________________________________________________________________________
conv2d_7 (Conv2D)               (None, 13, 13, 64)   2112        add_1[0][0]                      
__________________________________________________________________________________________________
conv2d_6 (Conv2D)               (None, 13, 13, 64)   36928       activation_4[0][0]               
__________________________________________________________________________________________________
add_2 (Add)                     (None, 13, 13, 64)   0           conv2d_7[0][0]                   
                                                                 conv2d_6[0][0]                   
__________________________________________________________________________________________________
batch_normalization_5 (BatchNor (None, 13, 13, 64)   256         add_2[0][0]                      
__________________________________________________________________________________________________
activation_5 (Activation)       (None, 13, 13, 64)   0           batch_normalization_5[0][0]      
__________________________________________________________________________________________________
conv2d_8 (Conv2D)               (None, 7, 7, 128)    73856       activation_5[0][0]               
__________________________________________________________________________________________________
batch_normalization_6 (BatchNor (None, 7, 7, 128)    512         conv2d_8[0][0]                   
__________________________________________________________________________________________________
activation_6 (Activation)       (None, 7, 7, 128)    0           batch_normalization_6[0][0]      
__________________________________________________________________________________________________
conv2d_10 (Conv2D)              (None, 7, 7, 128)    8320        add_2[0][0]                      
__________________________________________________________________________________________________
conv2d_9 (Conv2D)               (None, 7, 7, 128)    147584      activation_6[0][0]               
__________________________________________________________________________________________________
add_3 (Add)                     (None, 7, 7, 128)    0           conv2d_10[0][0]                  
                                                                 conv2d_9[0][0]                   
__________________________________________________________________________________________________
flatten_1 (Flatten)             (None, 6272)         0           add_3[0][0]                      
__________________________________________________________________________________________________
activation_7 (Activation)       (None, 6272)         0           flatten_1[0][0]                  
__________________________________________________________________________________________________
dropout_1 (Dropout)             (None, 6272)         0           activation_7[0][0]               
__________________________________________________________________________________________________
dense_2 (Dense)                 (None, 1)            6273        dropout_1[0][0]                  
__________________________________________________________________________________________________
dense_1 (Dense)                 (None, 1)            6273        dropout_1[0][0]                  
__________________________________________________________________________________________________
activation_8 (Activation)       (None, 1)            0           dense_2[0][0]                    
==================================================================================================
Total params: 321,634
Trainable params: 320,930
Non-trainable params: 704
__________________________________________________________________________________________________
None
configure_output_dir: not storing the git diff, probably because you're not in a git repo
Logging data to ./model/test_1/log.txt
/home/anaconda2/envs/dronet/lib/python3.5/site-packages/tensorflow/python/ops/gradients_impl.py:91: UserWarning: Converting sparse IndexedSlices to a dense Tensor of unknown shape. This may consume a large amount of memory.
  "Converting sparse IndexedSlices to a dense Tensor of unknown shape. "
Epoch 1/150
1.0
0.0
Traceback (most recent call last):
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/utils/data_utils.py", line 564, in get
    inputs = self.queue.get(block=True).get()
  File "/home/anaconda2/envs/dronet/lib/python3.5/multiprocessing/pool.py", line 644, in get
    raise self._value
  File "/home/anaconda2/envs/dronet/lib/python3.5/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/utils/data_utils.py", line 390, in get_index
    return _SHARED_SEQUENCES[uid][i]
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/preprocessing/image.py", line 799, in __getitem__
    return self._get_batches_of_transformed_samples(index_array)
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/preprocessing/image.py", line 845, in _get_batches_of_transformed_samples
    raise NotImplementedError
NotImplementedError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pytest/dronet/rpg_public_dronet-master1/cnn.py", line 176, in <module>
    main(sys.argv)
  File "/home/pytest/dronet/rpg_public_dronet-master1/cnn.py", line 172, in main
    _main()
  File "/home/pytest/dronet/rpg_public_dronet-master1/cnn.py", line 161, in _main
    trainModel(train_generator, val_generator, model, initial_epoch)
  File "/home/pytest/dronet/rpg_public_dronet-master1/cnn.py", line 89, in trainModel
    initial_epoch=initial_epoch)
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
    return func(*args, **kwargs)
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/engine/training.py", line 2212, in fit_generator
    generator_output = next(output_generator)
  File "/home/anaconda2/envs/dronet/lib/python3.5/site-packages/keras/utils/data_utils.py", line 570, in get
    six.raise_from(StopIteration(e), e)
  File "<string>", line 2, in raise_from
StopIteration

xiongdemao avatar Mar 24 '18 13:03 xiongdemao

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.

dsxxxk avatar Apr 19 '18 10:04 dsxxxk

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

MerouaneB avatar Apr 21 '18 15:04 MerouaneB

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               

antonilo avatar Apr 26 '18 22:04 antonilo

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

MerouaneB avatar May 03 '18 08:05 MerouaneB

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

antonilo avatar May 03 '18 16:05 antonilo

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'

MerouaneB avatar May 04 '18 08:05 MerouaneB

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

MerouaneB avatar May 04 '18 13:05 MerouaneB

@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!

jmidwint avatar May 05 '18 18:05 jmidwint

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])

MerouaneB avatar May 07 '18 08:05 MerouaneB

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

antonilo avatar May 09 '18 17:05 antonilo

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

antonilo avatar May 18 '18 00:05 antonilo