numpy.Inf

Here are the examples of the python api numpy.Inf taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

311 Examples 7

3 Source : Chapter_15.1_Rod_Cutting.py
with GNU General Public License v3.0
from absognety

def cut_rod(p,n):
    if n == 0:
        return 0
    q = -1 * np.Inf
    for i in range(1,n+1):
        q = max(q,p[i]+cut_rod(p,n-i))
    return q

3 Source : test_protocol.py
with Apache License 2.0
from Accenture

def test_evaluate_performance_so_side_corruptions_with_filter():
    X = load_wn18()
    model = ComplEx(batches_count=10, seed=0, epochs=5, k=200, eta=10, loss='nll',
                    regularizer=None, optimizer='adam', optimizer_params={'lr': 0.01}, verbose=True)
    model.fit(X['train'])

    ranks = evaluate_performance(X['test'][::20], model=model, verbose=True, corrupt_side='s+o')
    mrr = mrr_score(ranks)
    hits_10 = hits_at_n_score(ranks, n=10)
    print("ranks: %s" % ranks)
    print("MRR: %f" % mrr)
    print("Hits@10: %f" % hits_10)
    assert(mrr is not np.Inf)


@pytest.mark.skip(reason="CircleCI free tier upper bound investigation")

3 Source : basenetwork.py
with GNU Affero General Public License v3.0
from Aifred-Health

        def __init__(self, patience=2, verbose=False):
            """ Initialize early stopping """
            self.patience = patience
            self.verbose = verbose
            self.counter = 0
            self.best_score = None
            self.early_stop = False
            self.val_loss_min = np.Inf
            self.best_model = None
            self.save_path = ""

        def __call__(self, score, model):

3 Source : utils.py
with MIT License
from AmirooR

    def __init__(self, patience=7, verbose=False, delta=0):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement. 
                            Default: False
            delta (float): Minimum change in the monitored quantity to qualify as an improvement.
                            Default: 0
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf
        self.delta = delta

    def __call__(self, val_loss, model):

3 Source : ratio_feature.py
with Apache License 2.0
from Auquan

    def computeForInstrument(cls, updateNum, time, featureParams, featureKey, instrumentManager):
        instrumentLookbackData = instrumentManager.getLookbackInstrumentFeatures()
        if len(instrumentLookbackData.getFeatureDf(featureParams['featureName1']))>0:
            feature1 = instrumentLookbackData.getFeatureDf(featureParams['featureName1']).iloc[-1]
            feature2 = instrumentLookbackData.getFeatureDf(featureParams['featureName2']).iloc[-1]

            toRtn = feature1 / feature2
            toRtn[toRtn == np.Inf] = 0
        else:
            toRtn=0    
        return toRtn

    '''

3 Source : vwap_price_feature.py
with Apache License 2.0
from Auquan

    def computeForInstrument(cls, updateNum, time, featureParams, featureKey, instrumentManager):
        instrumentLookbackData = instrumentManager.getLookbackInstrumentFeatures()
        askVolume = instrumentLookbackData.getFeatureDf(featureParams['askVolume']).iloc[-1]
        bidVolume = instrumentLookbackData.getFeatureDf(featureParams['bidVolume']).iloc[-1]
        askPrice = instrumentLookbackData.getFeatureDf(featureParams['askPrice']).iloc[-1]
        bidPrice = instrumentLookbackData.getFeatureDf(featureParams['bidPrice']).iloc[-1]

        totalVolume = (askVolume + bidVolume)
        vwap = ((askPrice * askVolume) + (bidPrice * bidVolume)) / totalVolume

        vwap[vwap == np.Inf] = 0
        return vwap

    '''

3 Source : lr_schedule.py
with MIT License
from AxelJanRousseau

    def _reset(self):
        """Resets wait counter and cooldown counter.
    """

        self.monitor_op = lambda a, b: np.less(a, b * ( 1 - self.min_delta )) # same as torch default
        self.best = np.Inf

        self.cooldown_counter = 0
        self.wait = 0

    def on_epoch_end(self, epoch, val_loss):

3 Source : evaluation.py
with BSD 3-Clause "New" or "Revised" License
from batra-mlp-lab

    def nearest_node(self):
        ''' Get to the euclidean nearest graph node '''
        trans,rot = self.get_loc()

        min_dist = np.Inf
        viewpoint = None
        for node in nx.nodes(self.graph):
            pos = self.graph.node[node]['position']
            dist = math.sqrt((pos[0]-trans[0])**2+(pos[1]-trans[1])**2)
            if dist   <   min_dist:
                min_dist = dist
                viewpoint = node
        return viewpoint


    def go_send_nearest_instruction(self, cancel_on_fail=False):

3 Source : agent.py
with MIT License
from bic4907

    def get_lowest_cost_action_and_goal(self, start_pos_and_or, motion_goals):
        """
        Chooses motion goal that has the lowest cost action plan.
        Returns the motion goal itself and the first action on the plan.
        """
        min_cost = np.Inf
        best_action, best_goal = None, None
        for goal in motion_goals:
            action_plan, _, plan_cost = self.mlam.motion_planner.get_plan(start_pos_and_or, goal)
            if plan_cost   <   min_cost:
                best_action = action_plan[0]
                min_cost = plan_cost
                best_goal = goal
        return best_goal, best_action

    def boltzmann_rational_ll_action(self, start_pos_and_or, goal, inverted_costs=False):

3 Source : planners.py
with MIT License
from bic4907

    def get_gridworld_pos_distance(self, pos1, pos2):
        """Minimum (over possible orientations) number of actions necessary 
        to go from starting position to goal position (not including 
        interaction action)."""
        # NOTE: currently unused, pretty bad code. If used in future, clean up
        min_cost = np.Inf
        for d1, d2 in itertools.product(Direction.ALL_DIRECTIONS, repeat=2):
            start = (pos1, d1)
            end = (pos2, d2)
            if self.is_valid_motion_start_goal_pair(start, end):
                plan_cost = self.get_gridworld_distance(start, end)
                if plan_cost   <   min_cost:
                    min_cost = plan_cost
        return min_cost

    def _populate_all_plans(self):

3 Source : utils.py
with MIT License
from caokai1073

    def __init__(self, patience=10, verbose=False, checkpoint_file=''):
        """
        Parameters
        ----------
        patience 
            How long to wait after last time loss improved. Default: 30
        verbose
            If True, prints a message for each loss improvement. Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.loss_min = np.Inf
        self.checkpoint_file = checkpoint_file

    def __call__(self, loss, model):

3 Source : hist_callback.py
with MIT License
from CG1507

	def on_train_begin(self, logs=None):
		# Allow instances to be re-used
		self.wait = 0
		self.stopped_epoch = 0
		if self.baseline is not None:
			self.best = self.baseline
		else:
			self.best = np.Inf if self.monitor_op == np.less else -np.Inf

	def on_epoch_end(self, epoch, logs=None):

3 Source : pytorchtools.py
with MIT License
from csjtx1021

    def __init__(self, patience=7, verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement. 
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def __call__(self, val_loss, model):

3 Source : tools.py
with Apache License 2.0
from cure-lab

    def __init__(self, patience=7, verbose=False, delta=0):
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf
        self.delta = delta

    def __call__(self, val_loss, model, path):

3 Source : model_lib.py
with Apache License 2.0
from CuteChibiko

    def on_train_begin(self, logs={}):
        self.wait = 0
        self.best_epoch = 0
        self.stopped_epoch = 0
        self.best = -np.Inf
    def on_train_end(self, logs={}):

3 Source : cf_early_stopping.py
with MIT License
from d909b

    def on_train_begin(self, logs=None):
        # Allow instances to be re-used
        self.wait = 0
        self.stopped_epoch = 0
        self.best = np.Inf if self.monitor_op == np.less else -np.Inf

    def on_epoch_end(self, epoch, logs=None):

3 Source : affinity.py
with MIT License
from daip13

    def compute(self, node_from, node_to, camera_view = None, valid = None):
        data, atype = self._affinity_list[0].compute(node_from, node_to, camera_view, valid=valid)
        if atype == AffinityOutputType.Sparse:
            ret = sparsemat2dense(data, (len(node_from), len(node_to)))
        else:
            ret = data

        for i in range(1, len(self._affinity_list)):
            data, atype = self._affinity_list[i].compute(node_from, node_to, camera_view, valid=valid)
            if atype == AffinityOutputType.Sparse:
                mat = sparse2dense(data, len(node_to))
            else:
                mat = data
            ret += mat

        ret[ret > self._abs_threshold] = np.Inf
        return ret, AffinityOutputType.Dense

    def __call__(self, node_from, node_to, camera_view=None):

3 Source : statistics.py
with MIT License
from danielnbarbosa

    def __init__(self):
        self.score = None
        self.avg_score = None
        self.std_dev = None
        self.scores = []                         # list containing scores from each episode
        self.avg_scores = []                     # list containing average scores after each episode
        self.scores_window = deque(maxlen=100)   # last 100 scores
        self.best_avg_score = -np.Inf            # best score for a single episode
        self.time_start = time.time()            # track cumulative wall time
        self.total_steps = 0                     # track cumulative steps taken
        self.writer = SummaryWriter()
        self.log_file_name = 'output.txt'
        # zero out current output file
        f = open(self.log_file_name,'w')
        f.close()

    def update(self, steps, rewards, i_episode):

3 Source : cauchy.py
with Apache License 2.0
from dbstein

def _Cauchy_Kernel_Apply_numba_dipole(s, t, dipstr, pot):
    for i in numba.prange(t.shape[0]):
        for j in range(s.shape[0]):
            if t[i] != s[j]: # this is ugly!
                pot[i] += dipstr[j]/(t[i]-s[j])
            else:
                pot[i] += np.Inf

def Cauchy_Kernel_Apply_numba(source, target, dipstr, weights=None):

3 Source : all_code.py
with MIT License
from Delphi89

    def __init__(self, patience=40, verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement. 
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def __call__(self, val_loss, model):

3 Source : all_code.py
with MIT License
from Delphi89

    def __init__(self, waiting=10, verbose=False):
        self.waiting = waiting
        self.verbose = verbose
        self.counter2 = 0
        self.best_score2 = None
        self.early_stop2 = False
        self.val_loss_min2 = np.Inf

    def __call__(self, val_loss, model):

3 Source : utils.py
with Apache License 2.0
from dmlc

    def __init__(self, patience=10, metric_fn=None,
                 min_delta=1e-4, baseline_value=None, max_value=np.Inf):
        self.patience = patience if patience > 0 else np.Inf
        self.metric_fn = metric_fn
        self.min_delta = np.abs(min_delta)
        self.baseline_value = baseline_value
        self.max_value = max_value
        self.reset()

    def reset(self):

3 Source : utils.py
with Apache License 2.0
from dmlc

    def reset(self):
        """reset the early stopper"""
        self.last_epoch = 0
        self.wait = 0
        self._should_stop = False
        self._message = ''
        if self.baseline_value is not None:
            self.best = self.baseline_value
        else:
            self.best = -np.Inf

    def update(self, metric_value, epoch=None):

3 Source : utils.py
with MIT License
from dongtsi

    def __init__(self, 
            dim, 
            normer="minmax",
            online_minmax=False): # whether fit_transform online (see Kitsune), *available only for normer="minmax"

        self.dim = dim # feature dimensionality
        self.normer = normer
        if self.normer == 'minmax':
            self.online_minmax = online_minmax
            self.norm_max = [-np.Inf] * self.dim
            self.norm_min = [np.Inf] * self.dim
        else:
            raise NotImplementedError # Implement other Normalizer here
        
    def fit_transform(self,train_feat):

3 Source : models.py
with MIT License
from dsgissin

    def __init__(self, filepath, monitor='val_acc', delay=50, verbose=0, weights=False):

        super(DelayedModelCheckpoint, self).__init__()
        self.monitor = monitor
        self.verbose = verbose
        self.filepath = filepath
        self.delay = delay
        if self.monitor == 'val_acc':
            self.best = -np.Inf
        else:
            self.best = np.Inf
        self.weights = weights

    def on_epoch_end(self, epoch, logs=None):

3 Source : callbacks.py
with MIT License
from EdisonLeeeee

    def on_train_begin(self, logs=None):
        # Allow instances to be re-used
        self.wait = 0
        self.stopped_epoch = 0
        self.best = np.Inf if self.monitor_op == np.less else -np.Inf
        self.best_weights = None

    def on_epoch_end(self, epoch, logs=None):

3 Source : early_stopping.py
with MIT License
from Enderdead

    def __init__(self, patience=7, path='.', verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement. 
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf
        self.path = path

    def __call__(self, model, loss=None, accuracy=None):

3 Source : MRFBeliefPropagation.py
with GNU General Public License v3.0
from evanseitz

def createBPalg(G,options):

    BPalg = dict(options=options,
                 G=G,
                 init_message = [], #% once set this is not modified for record
                 old_message = [],  #% this is updated with each iteration and is the last message before final iteration or convergence
                 new_message = [],  #% this is updated with each iteration and is the final message after the final iteration or convergence
                 nodeBel =[],
                 edgeBel =[],
                 alphaDamp = options['alphaDamp'],
                 eqnStates = options['eqnStates'],
                 bpError = [], #%sum(abs(BPalg.new_message - BPalg.old_message));
                 bpIter = 1,
                 convergence = 0, # % is set to 1 if converged, otherwise 0
                 convergenceIter = np.Inf)
    return BPalg


'''

3 Source : test_arbitrary_discretiser.py
with BSD 3-Clause "New" or "Revised" License
from feature-engine

def test_error_if_input_df_contains_na_in_transform(df_vartypes, df_na):
    # test case 1: when dataset contains na, transform method
    age_dict = {"Age": [0, 10, 20, 30, np.Inf]}

    with pytest.raises(ValueError):
        transformer = ArbitraryDiscretiser(binning_dict=age_dict)
        transformer.fit(df_vartypes)
        transformer.transform(df_na[["Name", "City", "Age", "Marks", "dob"]])


def test_error_when_nan_introduced_during_transform():

3 Source : mdaextractors.py
with Apache License 2.0
from flatironinstitute

    def get_unit_spike_train(self, unit_id, start_frame=None, end_frame=None):
        if start_frame is None:
            start_frame = 0
        if end_frame is None:
            end_frame = np.Inf
        inds = np.where((self._labels == unit_id) & (start_frame   <  = self._times) & (self._times  <  end_frame))
        return np.rint(self._times[inds]).astype(int)

    def get_sampling_frequency(self):

3 Source : nwbextractors.py
with Apache License 2.0
from flatironinstitute

    def get_unit_spike_train(self, unit_id, start_frame=None, end_frame=None):
        start_frame, end_frame = self._cast_start_end_frame(start_frame, end_frame)
        if start_frame is None:
            start_frame = 0
        if end_frame is None:
            end_frame = np.Inf
        check_nwb_install()
        with NWBHDF5IO(self._path, 'r') as io:
            nwbfile = io.read()
            # chosen unit and interval
            times = nwbfile.units['spike_times'][list(nwbfile.units.id[:]).index(unit_id)][:]
            # spike times are measured in samples
            frames = self.time_to_frame(times)
        return frames[(frames > start_frame) & (frames   <   end_frame)]

    def time_to_frame(self, time):

3 Source : early_stopping.py
with MIT License
from guillaumejaume

    def __init__(self, patience=7, verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement.
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def reset(self):

3 Source : early_stopping.py
with MIT License
from guillaumejaume

    def reset(self):
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def __call__(self, val_loss, model, save_path=''):

3 Source : cancelout.py
with MIT License
from haugjo

    def __init__(self, patience=7, verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement.
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def __call__(self, val_loss, model):

3 Source : training_tools.py
with MIT License
from JchenXu

    def reset(self, patience=7):
        self.patience = patience
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf


batch_size = 12

3 Source : earlystopping.py
with MIT License
from jhhuang96

    def __init__(self, patience=7, verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement. 
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def __call__(self, val_loss, model, epoch, save_path):

3 Source : hparams_tuning.py
with MIT License
from jonepatr

    def __init__(self, trial, monitor="val_loss", patience=2):
        super().__init__(trial, monitor=monitor)
        self.best_loss = torch.tensor(np.Inf)
        self.wait = 0
        self.patience = patience
        self.jerk_generated_means = []

    def on_train_batch_end(

3 Source : model.py
with MIT License
from jsxlei

    def __init__(self, patience=10, verbose=False, outdir='./'):
        """
        Args:
            patience (int): How long to wait after last time loss improved.
                            Default: 10
            verbose (bool): If True, prints a message for each loss improvement. 
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.loss_min = np.Inf
        self.model_file = os.path.join(outdir, 'model.pt')

    def __call__(self, loss, model):

3 Source : invert.py
with GNU Lesser General Public License v3.0
from jwallwork23

    def gradient(m):
        """
        Gradient of reduced functional for continuous adjoint inversion.
        """
        J = reduced_functional(m) if len(swp.checkpoint) == 0 else swp.quantity_of_interest()
        swp.solve_adjoint(checkpointing_mode=chk)
        g = np.array([
            assemble(inner(bf, swp.adj_solution)*dx) for bf in op.basis_functions
        ])  # TODO: No minus sign?
        if use_regularisation:
            g += op.regularisation_term_gradient
        msg = " functional = {:15.8e}  gradient = {:15.8e}"
        print_output(msg.format(J, vecnorm(g, order=np.Inf)))
        return g


# --- Taylor test

if taylor:

3 Source : invert.py
with GNU Lesser General Public License v3.0
from jwallwork23

        def derivative_cb_post(j, dj, m):
            """
            Callback for saving progress data to file during discrete adjoint inversion.
            """
            control = [mi.dat.data[0] for mi in m]
            djdm = [dji.dat.data[0] for dji in dj]
            msg = "functional {:15.8e}  gradient {:15.8e}"
            print_output(msg.format(j, vecnorm(djdm, order=np.Inf)))

            # Save progress to NumPy arrays on-the-fly
            control_values_opt.append(control)
            func_values_opt.append(j)
            gradient_values_opt.append(djdm)
            np.save(fname.format('ctrl'), np.array(control_values_opt))
            np.save(fname.format('func'), np.array(func_values_opt))
            np.save(fname.format('grad'), np.array(gradient_values_opt))

        # Run BFGS optimisation
        reduced_functional = ReducedFunctional(J, controls, derivative_cb_post=derivative_cb_post)  # noqa

3 Source : invert_source.py
with GNU Lesser General Public License v3.0
from jwallwork23

def gradient(m):
    """
    Compute the gradient of the QoI with respect to the input parameters.
    """
    dJdm = adolc.fos_reverse(tape_tag, 1.0)
    op.dJdm_progress.append(vecnorm(dJdm, order=np.Inf))
    return dJdm


J = reduced_functional(op.input_vector)

3 Source : norms.py
with GNU Lesser General Public License v3.0
from jwallwork23

def vecnorm(x, order=2):
    """
    Consistent with the norm used in `scipy/optimize.py`.
    """
    if order == np.Inf:
        return np.amax(np.abs(x))
    elif order == -np.Inf:
        return np.amin(np.abs(x))
    else:
        return np.sum(np.abs(x)**order, axis=0)**(1.0 / order)


def timeseries_error(f, g=None, relative=False, norm_type='tv'):

3 Source : _progress.py
with BSD 3-Clause "New" or "Revised" License
from keurfonluu

    def __init__(self, *args, **kwargs):
        """Custom progress bar with misfit information."""
        super().__init__(*args, **kwargs)

        self.width = 20
        self.suffix = (
            "%(percent)3d%% [%(elapsed_td)s / %(eta_td)s] - Misfit: %(misfit).4f"
        )
        self.check_tty = False
        self.misfit = np.Inf

    @property

3 Source : bus13_opt_action.py
with MIT License
from kevinrussellmoy

def opt_control(DSSCircuit, DSSSolution):

    # Get action with lowest reward
    opt_reward = -np.Inf
    opt_action = -np.Inf
    for action in range(TOTAL_ACTIONS):
        action_to_cap_control(action, DSSCircuit)
        DSSSolution.solve()
        observation = get_state(DSSCircuit)
        reward = quad_reward(observation)
        print("action=", action)
        print('reward=', reward)
        if reward > opt_reward:
            opt_action = action
            opt_reward = reward
    print("\nopt action = ", opt_action)
    print("opt reward = ", opt_reward)

    return opt_action, opt_reward

3 Source : forcefield_v1.py
with MIT License
from kul-group

def get_fitting_parameters(initial_param, info_dict, DFT_f, ini_bond_param_dict, ini_angle_param_dict,
                           bond_type_index_dict, angle_type_index_dict, EF_index):
    # todo: more flexible bond reformating and feeding
    bounds = ((-np.Inf, np.Inf), (-np.Inf, np.Inf), (0, np.Inf), (-np.Inf, np.Inf), (-np.Inf, np.Inf),
              (0, np.Inf), (-np.Inf, np.Inf), (-np.Inf, np.Inf), (0, np.Inf), (0, np.pi),
              (-np.Inf, np.Inf), (0, np.pi), (-np.Inf, np.Inf), (0, np.pi), (-np.Inf, np.Inf))
    res = minimize(get_residue, initial_param, method='Powell', bounds=bounds, options={'ftol': 0.01, 'maxiter': 1000},
                   args=(info_dict, DFT_f, ini_bond_param_dict, ini_angle_param_dict, bond_type_index_dict,
                         angle_type_index_dict, EF_index))
    print(res.success)
    return res


def make_parity_plot(ff_forces, dft_forces, atom_name):

3 Source : forcefield_v2.py
with MIT License
from kul-group

def get_fitting_parameters(initial_param, info_dict, DFT_f, weights, ini_bond_param_dict, ini_angle_param_dict,
                           bond_type_index_dict, angle_type_index_dict, EF_index):
    # todo: more flexible bond reformating and feeding
    bounds = ((-np.Inf, np.Inf), (-np.Inf, np.Inf), (0, np.Inf), (-np.Inf, np.Inf), (-np.Inf, np.Inf),
              (0, np.Inf), (-np.Inf, np.Inf), (-np.Inf, np.Inf), (0, np.Inf), (0, np.pi),
              (-np.Inf, np.Inf), (0, np.pi), (-np.Inf, np.Inf), (0, np.pi), (-np.Inf, np.Inf))
    res = minimize(get_residue, initial_param, method='Powell', bounds=bounds, options={'ftol': 0.01, 'maxiter': 1000},
                   args=(info_dict, DFT_f, weights, ini_bond_param_dict, ini_angle_param_dict,
                         bond_type_index_dict, angle_type_index_dict, EF_index))
    print(res.success)
    return res


def make_parity_plot(ff_forces, dft_forces, atom_name):

3 Source : utils.py
with MIT License
from Lee-Gihun

    def __init__(self, patience=10, verbose=False):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement. 
                            Default: False
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf

    def __call__(self, val_loss, model):

3 Source : early_stopping.py
with GNU Affero General Public License v3.0
from lironui

    def __init__(self, patience=7, verbose=False, delta=0):
        """
        Args:
            patience (int): How long to wait after last time validation loss improved.
                            Default: 7
            verbose (bool): If True, prints a message for each validation loss improvement.
                            Default: False
            delta (float): Minimum change in the monitored quantity to qualify as an improvement.
                            Default: 0
        """
        self.patience = patience
        self.verbose = verbose
        self.counter = 0
        self.best_score = None
        self.early_stop = False
        self.val_loss_min = np.Inf
        self.delta = delta

    def __call__(self, val_loss, model, path):

3 Source : earlystopping.py
with MIT License
from lonePatient

    def reset(self):
        # Allow instances to be re-used
        self.wait = 0
        self.stop_training = False
        if self.baseline is not None:
            self.best = self.baseline
        else:
            self.best = np.Inf if self.monitor_op == np.less else -np.Inf

    def epoch_step(self,current):

3 Source : custom_callback.py
with Apache License 2.0
from Lornatang

  def on_train_begin(self, logs=None):
    # The number of epoch it has waited when loss is no longer minimum.
    self.wait = 0
    # The epoch the training stops at.
    self.stopped_epoch = 0
    # Initialize the best as infinity.
    self.best = np.Inf

  def on_epoch_end(self, epoch, logs=None):

See More Examples