Skip to content

Commit

Permalink
Merge pull request #117 from lvapeab/master
Browse files Browse the repository at this point in the history
Avoid matplotlib warning
  • Loading branch information
lvapeab authored Jul 17, 2017
2 parents 8b4be05 + 246bcda commit 29e4ea0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
8 changes: 4 additions & 4 deletions keras_wrapper/cnn_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import matplotlib as mpl
mpl.use('Agg') # run matplotlib without X server (GUI)
import matplotlib.pyplot as plt
import numpy as np
import cPickle as pk
Expand Down Expand Up @@ -35,7 +36,6 @@


# General setup of libraries
mpl.use('Agg') # run matplotlib without X server (GUI)
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] %(message)s', datefmt='%d/%m/%Y %H:%M:%S')
logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1407,7 +1407,7 @@ def beam_search_NEW(self, X, params, null_sym=2, debug=False):
live_k[pos_sample] = new_live_k

if new_live_k > 0 and dead_k[pos_sample] < k:
# convert chosen samples
# convert chosen samples
state_below.append(np.asarray(hyp_samples[pos_sample], dtype='int64'))

# keep every remaining one
Expand Down Expand Up @@ -1683,7 +1683,7 @@ def predictBeamSearchNet_NEW(self, ds, parameters={}):
:param predict_on_sets: list of set splits for which we want to extract the predictions ['train', 'val', 'test']
:param optimized_search: boolean indicating if the used model has the optimized Beam Search implemented (separate self.model_init and self.model_next models for reusing the information from previous timesteps).
The following attributes must be inserted to the model when building an optimized search model:
* ids_inputs_init: list of input variables to model_init (must match inputs to conventional model)
* ids_outputs_init: list of output variables of model_init (model probs must be the first output)
* ids_inputs_next: list of input variables to model_next (previous word must be the first input)
Expand Down Expand Up @@ -1940,7 +1940,7 @@ def predictBeamSearchNet(self, ds, parameters={}):
:param predict_on_sets: list of set splits for which we want to extract the predictions ['train', 'val', 'test']
:param optimized_search: boolean indicating if the used model has the optimized Beam Search implemented (separate self.model_init and self.model_next models for reusing the information from previous timesteps).
The following attributes must be inserted to the model when building an optimized search model:
* ids_inputs_init: list of input variables to model_init (must match inputs to conventional model)
* ids_outputs_init: list of output variables of model_init (model probs must be the first output)
* ids_inputs_next: list of input variables to model_next (previous word must be the first input)
Expand Down
28 changes: 12 additions & 16 deletions keras_wrapper/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ def generator(self):
# ------------------------------------------------------- #
class Dataset(object):
"""
Class for defining instances of databases adapted for Keras. It includes several utility functions for easily managing
data splits, image loading, mean calculation, etc.
Class for defining instances of databases adapted for Keras. It includes several utility functions for
easily managing data splits, image loading, mean calculation, etc.
"""

def __init__(self, name, path, silence=False):
Expand All @@ -375,7 +375,7 @@ def __init__(self, name, path, silence=False):
# Variable for storing external extra variables
self.extra_variables = dict()

############################ Data loading parameters
# Data loading parameters
# Lock for threads synchronization
self.__lock_read = threading.Lock()

Expand Down Expand Up @@ -410,7 +410,7 @@ def __init__(self, name, path, silence=False):

#################################################

############################ Parameters for managing all the inputs and outputs
# Parameters for managing all the inputs and outputs
# List of identifiers for the inputs and outputs and their respective types
# (which will define the preprocessing applied)
self.ids_inputs = []
Expand Down Expand Up @@ -443,7 +443,7 @@ def __init__(self, name, path, silence=False):
self.__available_augm_vid_feat = ['random_selection', 'noise'] # 'video-features' only
#################################################

############################ Parameters used for inputs/outputs of type 'text'
# Parameters used for inputs/outputs of type 'text'
self.extra_words = {'<pad>': 0, '<unk>': 1, '<null>': 2} # extra words introduced in all vocabularies
self.vocabulary = dict() # vocabularies (words2idx and idx2words)
self.max_text_len = dict() # number of words accepted in a 'text' sample
Expand All @@ -461,17 +461,17 @@ def __init__(self, name, path, silence=False):
self.BPE_built = False
#################################################

############################ Parameters used for inputs of type 'video' or 'video-features'
# Parameters used for inputs of type 'video' or 'video-features'
self.counts_frames = dict()
self.paths_frames = dict()
self.max_video_len = dict()
#################################################

############################ Parameters used for inputs of type 'image-features' or 'video-features'
# Parameters used for inputs of type 'image-features' or 'video-features'
self.features_lengths = dict()
#################################################

############################ Parameters used for inputs of type 'raw-image'
# Parameters used for inputs of type 'raw-image'
# Image resize dimensions used for all the returned images
self.img_size = dict()
# Image crop dimensions for the returned images
Expand All @@ -482,21 +482,21 @@ def __init__(self, name, path, silence=False):
self.use_RGB = dict()
#################################################

############################ Parameters used for outputs of type 'categorical', '3DLabels' or '3DSemanticLabel'
# Parameters used for outputs of type 'categorical', '3DLabels' or '3DSemanticLabel'
self.classes = dict()
self.dic_classes = dict()
#################################################

############################ Parameters used for outputs of type '3DLabels' or '3DSemanticLabel'
# Parameters used for outputs of type '3DLabels' or '3DSemanticLabel'
self.id_in_3DLabel = dict()
self.num_poolings_model = dict()
#################################################

############################ Parameters used for outputs of type '3DSemanticLabel'
# Parameters used for outputs of type '3DSemanticLabel'
self.semantic_classes = dict()
#################################################

############################ Parameters used for outputs of type 'sparse'
# Parameters used for outputs of type 'sparse'
self.sparse_binary = dict()
#################################################

Expand Down Expand Up @@ -531,10 +531,6 @@ def keepTopOutputs(self, set_name, id_out, n_top):
raise Exception("The parameter 'id_out' must specify a valid id for an output of the dataset.\n"
"Error produced because parameter %s was not in %s" % (id_out, self.ids_outputs))

# type_out = self.types_outputs(self.ids_outputs.index(id_out))
# if type_out != 'text':
# raise Exception("This method is only applicable to outputs of type 'text'.")

logging.info('Keeping top ' + str(n_top) + ' outputs from the ' + set_name + ' set and removing the rest.')

# Sort outputs by number of occurrences
Expand Down

0 comments on commit 29e4ea0

Please sign in to comment.