How to use the dill.load_session function in dill

To help you get started, we’ve selected a few dill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bastibe / RunForrest / runforrest.py View on Github external
def run_task(infile, outfile, sessionfile, do_print, do_raise):
    """Execute `infile` and produce `outfile`.

    If `sessionfile` is given, load session from that file.

    Set `do_print` or `do_raise` to `True` if errors should be printed or
    raised.

    """

    if sessionfile:
        dill.load_session(Path(sessionfile))

    with infile.open('rb') as f:
        task = dill.load(f)

    try:
        start_time = time.perf_counter()
        task.returnvalue = evaluate(task)
        task.errorvalue = None
    except Exception as err:
        task.errorvalue = err
        task.returnvalue = None
    finally:
        task.runtime = time.perf_counter() - start_time
        with outfile.open('wb') as f:
            dill.dump(task, f)
github sar-gupta / neural-network-from-scratch / neuralnetwork.py View on Github external
def check_accuracy(self, filename, inputs, labels):
        dill.load_session(filename)
        self.batch_size = len(inputs)
        self.forward_pass(inputs)
        a = self.layers[self.num_layers-1].activations
        a[np.where(a==np.max(a))] = 1
        a[np.where(a!=np.max(a))] = 0
        total=0
        correct=0
        for i in range(len(a)):
            total += 1
            if np.equal(a[i], labels[i]).all():
                correct += 1
        print("Accuracy: ", correct*100/total)
github PYFTS / pyFTS / pyFTS / common / Util.py View on Github external
def load_env(file):
    dill.load_session(file)
github sar-gupta / neural-network-from-scratch / neuralnetwork.py View on Github external
def load_model(self, filename):
        dill.load_session(filename)
github axbaretto / beam / sdks / python / apache_beam / internal / pickler.py View on Github external
def load_session(file_path):
  with _pickle_lock_unless_py2:
    return dill.load_session(file_path)
github axbaretto / beam / sdks / python / apache_beam / internal / pickler.py View on Github external
def dump_session(file_path):
  """For internal use only; no backwards-compatibility guarantees.

  Pickle the current python session to be used in the worker.

  Note: Due to the inconsistency in the first dump of dill dump_session we
  create and load the dump twice to have consistent results in the worker and
  the running session. Check: https://github.com/uqfoundation/dill/issues/195
  """
  with _pickle_lock_unless_py2:
    dill.dump_session(file_path)
    dill.load_session(file_path)
    return dill.dump_session(file_path)
github OpenGenus / cosmos / code / artificial_intelligence / src / neural_network / neuralnetwork.py View on Github external
def check_accuracy(self, filename, inputs, labels):
        dill.load_session(filename)
        self.batch_size = len(inputs)
        self.forward_pass(inputs)
        a = self.layers[self.num_layers - 1].activations
        num_classes = 10
        targets = np.array([a]).reshape(-1)
        a = np.asarray(a)
        one_hot_labels = np.eye(num_classes)[a.astype(int)]
        total = 0
        correct = 0
        for i in range(len(a)):
            total += 1
            if np.equal(one_hot_labels[i], labels[i]).all():
                correct += 1
        print("Accuracy: ", correct * 100 / total)