Python keras.callbacks.Callback.__init__() Examples

The following are 30 code examples of keras.callbacks.Callback.__init__(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module keras.callbacks.Callback , or try the search function .
Example #1
Source File: keras_callbacks.py    From agnez with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def __init__(self, name, fig_title, url):
        """
        fig_title: Figure Title
        url : str, optional
            Url of the bokeh-server. Ex: when starting the bokeh-server with
            ``bokeh-server --ip 0.0.0.0`` at ``alice``, server_url should be
            ``http://alice:5006``. When not specified the default configured
            by ``bokeh_server`` in ``.blocksrc`` will be used. Defaults to
            ``http://localhost:5006/``.

        Reference: mila-udem/blocks-extras
        """
        Callback.__init__(self)
        self.name = name
        self.fig_title = fig_title
        self.plots = []
        output_server(name, url=url)
        cursession().publish() 
Example #2
Source File: Keras_utils.py    From coling2018_fake-news-challenge with Apache License 2.0 6 votes vote down vote up
def __init__(self, log_dir='./logs',
                 histogram_freq=0,
                 batch_size=32,
                 write_graph=True,
                 write_grads=False,
                 write_images=False,
                 embeddings_freq=0,
                 embeddings_layer_names=None,
                 embeddings_metadata=None):
        super(TensorBoard, self).__init__()
        if K.backend() != 'tensorflow':
            raise RuntimeError('TensorBoard callback only works '
                               'with the TensorFlow backend.')
        self.log_dir = log_dir
        self.histogram_freq = histogram_freq
        self.merged = None
        self.write_graph = write_graph
        self.write_grads = write_grads
        self.write_images = write_images
        self.embeddings_freq = embeddings_freq
        self.embeddings_layer_names = embeddings_layer_names
        self.embeddings_metadata = embeddings_metadata or {}
        self.batch_size = batch_size 
Example #3
Source File: Keras_utils.py    From coling2018_fake-news-challenge with Apache License 2.0 6 votes vote down vote up
def __init__(self, epochs,
                 X_test_claims,
                 X_test_orig_docs,
                 y_test, loss_filename, epsilon=0.0, min_epoch = 15, X_test_nt=None):
        self.epochs = epochs
        self.patience = 2
        self.counter = 0
        self.prev_score = 0
        self.epsilon = epsilon
        self.loss_filename = loss_filename
        self.min_epoch = min_epoch
        self.X_test_nt = X_test_nt
        #self.print_train_f1 = print_train_f1

        #self.X_train_claims = X_train_claims
        #self.X_train_orig_docs = X_train_orig_docs
        #self.X_train_evid = X_train_evid
        #self.y_train = y_train

        self.X_test_claims = X_test_claims
        self.X_test_orig_docs = X_test_orig_docs
        self.y_test = y_test
        Callback.__init__(self) 
Example #4
Source File: uno_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, rate, **kwargs):
        super(PermanentDropout, self).__init__(rate, **kwargs)
        self.uses_learning_phase = False 
Example #5
Source File: combo_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, data, partition='train', batch_size=32):
        self.lock = threading.Lock()
        self.data = data
        self.partition = partition
        self.batch_size = batch_size

        if partition == 'train':
            self.cycle = cycle(range(data.n_train))
            self.num_data = data.n_train
        elif partition == 'val':
            self.cycle = cycle(range(data.total)[-data.n_val:])
            self.num_data = data.n_val
        else:
            raise Exception('Data partition "{}" not recognized.'.format(partition)) 
Example #6
Source File: combo_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, print_fcn=print):
        Callback.__init__(self)
        self.print_fcn = print_fcn 
Example #7
Source File: combo_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, rate, **kwargs):
        super(PermanentDropout, self).__init__(rate, **kwargs)
        self.uses_learning_phase = False 
Example #8
Source File: combo_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, save_all_models=False):
        Callback.__init__(self)
        self.save_all_models = save_all_models
        get_custom_objects()['PermanentDropout'] = PermanentDropout 
Example #9
Source File: uno_model_utils.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, save_all_models=False):
        Callback.__init__(self)
        self.save_all_models = save_all_models
        candle.register_permanent_dropout() 
Example #10
Source File: uno_model_utils.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, fname):
        self.fname = fname 
Example #11
Source File: uno_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, print_fcn=print):
        Callback.__init__(self)
        self.print_fcn = print_fcn 
Example #12
Source File: combo_dose.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, print_fcn=print):
        Callback.__init__(self)
        self.print_fcn = print_fcn 
Example #13
Source File: uno_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, fname):
        self.fname = fname 
Example #14
Source File: uno_clr_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, print_fcn=print):
        Callback.__init__(self)
        self.print_fcn = print_fcn 
Example #15
Source File: uno_clr_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, rate, **kwargs):
        super(PermanentDropout, self).__init__(rate, **kwargs)
        self.uses_learning_phase = False 
Example #16
Source File: uno_clr_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, fname):
        self.fname = fname 
Example #17
Source File: uno_clr_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, **entries):
        self.__dict__.update(entries) 
Example #18
Source File: keras_utils.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, rate, **kwargs):
        super(PermanentDropout, self).__init__(rate, **kwargs)
        self.uses_learning_phase = False 
Example #19
Source File: combo_dose.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, **entries):
        self.__dict__.update(entries) 
Example #20
Source File: combo_dose.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, rate, **kwargs):
        super(PermanentDropout, self).__init__(rate, **kwargs)
        self.uses_learning_phase = False 
Example #21
Source File: combo_dose.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, data, partition='train', batch_size=32):
        self.lock = threading.Lock()
        self.data = data
        self.partition = partition
        self.batch_size = batch_size

        if partition == 'train':
            self.cycle = cycle(range(data.n_train))
            self.num_data = data.n_train
        elif partition == 'val':
            self.cycle = cycle(range(data.total)[-data.n_val:])
            self.num_data = data.n_val
        else:
            raise Exception('Data partition "{}" not recognized.'.format(partition)) 
Example #22
Source File: attn_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, print_fcn=print):
        Callback.__init__(self)
        self.print_fcn = print_fcn 
Example #23
Source File: p1b1_baseline_keras2.py    From Benchmarks with MIT License 5 votes vote down vote up
def __init__(self, print_fcn=print):
        Callback.__init__(self)
        self.print_fcn = print_fcn 
Example #24
Source File: util.py    From lyapy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, loss_threshold):
		Callback.__init__(self)
		self.loss_threshold = loss_threshold 
Example #25
Source File: timing.py    From keras_experiments with The Unlicense 5 votes vote down vote up
def __init__(self, batch_size, **kwargs):
        Callback.__init__(self, **kwargs)
        self.batch_size = batch_size

        self.all_samples_per_sec = None
        self.start_time = None 
Example #26
Source File: timing.py    From keras_experiments with The Unlicense 5 votes vote down vote up
def __init__(self):
        Callback.__init__(self)
        self.train_beg_time = None
        self.all_batch_times = None
        self.all_epoch_times = None

        self.epoch_batch_times = None
        self._epoch_start_time = None

        self.start_time = None 
Example #27
Source File: progress.py    From KerasUI with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, dataset_id):
        Callback.__init__(self)
        self.seen = 0
        self.dataset_id = dataset_id
        
        self.samples=1000
        self.oldperc=0
       # print('inited '+self.samples+' '+self.dataset_id) 
Example #28
Source File: tf_keras.py    From imageatm with Apache License 2.0 5 votes vote down vote up
def __init__(
        self,
        filepath: Path,
        logger: Logger,
        monitor: str = 'val_loss',
        verbose: int = 0,
        save_best_only: bool = False,
        save_weights_only: bool = False,
        mode: str = 'auto',
        period: int = 1,
    ) -> None:
        self.monitor = monitor
        self.verbose = verbose
        self.filepath = filepath
        self.save_best_only = save_best_only
        self.save_weights_only = save_weights_only
        self.period = period
        self.epochs_since_last_save = 0
        self.logger = logger

        if mode not in ['auto', 'min', 'max']:
            self.logger.warning(
                'ModelCheckpoint mode {} is unknown, fallback to auto mode.'.format(mode)
            )
            mode = 'auto'

        if mode == 'min':
            self.monitor_op = np.less
            self.best = np.Inf
        elif mode == 'max':
            self.monitor_op = np.greater
            self.best = -np.Inf
        else:
            if 'acc' in self.monitor or self.monitor.startswith('fmeasure'):
                self.monitor_op = np.greater
                self.best = -np.Inf
            else:
                self.monitor_op = np.less
                self.best = np.Inf 
Example #29
Source File: tf_keras.py    From imageatm with Apache License 2.0 5 votes vote down vote up
def __init__(self, logger: Logger) -> None:
        Callback.__init__(self)
        self.logger = logger
        self.format_epoch = 'Epoch: {} - {}'
        self.format_keyvalue = '{}: {:0.4f}'
        self.format_separator = ' - ' 
Example #30
Source File: keras_callbacks.py    From agnez with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, filepath, X, func, how_often=10, display=None):
        super(Callback, self).__init__()
        self.filepath = filepath
        self.how_often = how_often
        self.display = display
        self.X = X
        self.func = func