Exemplo n.º 1
0
    def _fit_on_prepared_data(self,
                              backend,
                              train_rows,
                              val_rows,
                              metadata,
                              avg_row_size,
                              dataset_idx=None):
        self._check_params(metadata)
        keras_utils = self._get_keras_utils()

        run_id = self.getRunId()
        if run_id is None:
            run_id = 'keras_' + str(int(time.time()))

        if self._has_checkpoint(run_id):
            serialized_model = self._load_model_from_checkpoint(run_id)
        else:
            serialized_model = self._compile_model(keras_utils)

        # Workaround:
        # https://stackoverflow.com/questions/50583056/is-there-any-way-to-set-java-opts-for-tensorflow-process/50615570
        env = {'LIBHDFS_OPTS': '-Xms2048m -Xmx2048m'}

        trainer = remote.RemoteTrainer(self, metadata, keras_utils, run_id,
                                       dataset_idx)
        handle = backend.run(trainer,
                             args=(serialized_model, train_rows, val_rows,
                                   avg_row_size),
                             env=env)
        return self._create_model(handle, run_id, metadata)
Exemplo n.º 2
0
    def _fit_on_prepared_data(self,
                              backend,
                              train_rows,
                              val_rows,
                              metadata,
                              avg_row_size,
                              dataset_idx=None):
        self._check_params(metadata)
        keras_utils = self._get_keras_utils()

        run_id = self.getRunId()
        if run_id is None:
            run_id = 'keras_' + str(int(time.time()))

        if self._has_checkpoint(run_id):
            serialized_model = self._load_model_from_checkpoint(run_id)
        else:
            serialized_model = self._compile_model(keras_utils)

        trainer = remote.RemoteTrainer(self, metadata, keras_utils, run_id,
                                       dataset_idx)
        handle = backend.run(trainer,
                             args=(serialized_model, train_rows, val_rows,
                                   avg_row_size),
                             env=self.getBackendEnv())
        return self._create_model(handle, run_id, metadata)