コード例 #1
0
    def fit(self, train_x, train_y, validation_data_fit, train_loop_num,
            **kwargs):
        val_x, val_y = validation_data_fit
        epochs = 5
        patience = 2
        batch_size = 32
        # over_batch = len(train_x) % batch_size
        # append_idx = np.random.choice(np.arange(len(train_x)), size=batch_size-over_batch, replace=False)
        # train_x = np.concatenate([train_x, train_x[append_idx]], axis=0)
        # train_y = np.concatenate([train_y, train_y[append_idx]], axis=0)

        callbacks = [
            tf.keras.callbacks.EarlyStopping(monitor='val_loss',
                                             patience=patience)
        ]

        self._model.fit(
            train_x,
            ohe2cat(train_y),
            epochs=epochs,
            callbacks=callbacks,
            validation_data=(val_x, ohe2cat(val_y)),
            verbose=1,  # Logs once per epoch.
            batch_size=batch_size,
            shuffle=True)
コード例 #2
0
 def fit(self, train_x, train_y, validation_data_fit,
         train_loop_num, **kwargs):
     val_x, val_y = validation_data_fit
     epochs = 10
     patience = 2
     callbacks = [
         tf.keras.callbacks.EarlyStopping(
             monitor='val_loss',
             patience=patience)]
     self._model.fit(train_x, ohe2cat(train_y),
                     epochs=epochs,
                     callbacks=callbacks,
                     validation_data=(val_x, ohe2cat(val_y)),
                     verbose=1,  # Logs once per epoch.
                     batch_size=32,
                     shuffle=True)
コード例 #3
0
ファイル: cnn.py プロジェクト: MetaLearners/AutoDL-Challenge
 def fit(self, train_x, train_y, validation_data_fit, train_loop_num,
         **kwargs):
     val_x, val_y = validation_data_fit
     callbacks = [
         tf.keras.callbacks.EarlyStopping(monitor='val_loss', patience=3)
     ]
     epochs = 10 if train_loop_num == 1 else 30
     log('train_x: ' + str(train_x.shape) + '; train_y: ' +
         str(train_y.shape) + '')
     self._model.fit(
         train_x,
         ohe2cat(train_y),
         epochs=epochs,
         callbacks=callbacks,
         validation_data=(val_x, ohe2cat(val_y)),
         verbose=1,  # Logs once per epoch.
         batch_size=32,
         shuffle=True)
コード例 #4
0
    def fit(self, train_x, train_y, validation_data_fit, round_num, **kwargs):
        val_x, val_y = validation_data_fit

        # if train_loop_num == 1:
        #     patience = 2
        #     epochs = 3
        # elif train_loop_num == 2:
        #     patience = 3
        #     epochs = 10
        # elif train_loop_num < 10:
        #     patience = 4
        #     epochs = 16
        # elif train_loop_num < 15:
        #     patience = 4
        #     epochs = 24
        # else:
        #     patience = 8
        #     epochs = 32

        patience = 2
        # epochs = self.epoch_cnt + 3
        epochs = 10
        callbacks = [
            tf.keras.callbacks.EarlyStopping(
                monitor='val_loss',
                patience=patience)]

        self._model.fit(train_x, ohe2cat(train_y),
                        epochs=epochs,
                        callbacks=callbacks,
                        validation_data=(val_x, ohe2cat(val_y)),
                        # validation_split=0.2,
                        verbose=VERBOSE,  # Logs once per epoch.
                        batch_size=32,
                        shuffle=True,
                        # initial_epoch=self.epoch_cnt,
                        # use_multiprocessing=True
                        )
        self.epoch_cnt += 3
コード例 #5
0
ファイル: cnn.py プロジェクト: MetaLearners/AutoDL-Challenge
    def fit(self, train_x, train_y, validation_data_fit, train_loop_num,
            **kwargs):
        val_x, val_y = validation_data_fit

        # if train_loop_num == 1:
        #     patience = 2
        #     epochs = 8
        # elif train_loop_num == 2:
        #     patience = 3
        #     epochs = 10
        # elif train_loop_num < 10:
        #     patience = 4
        #     epochs = 16
        # elif train_loop_num < 15:
        #     patience = 4
        #     epochs = 24
        # else:
        #     patience = 8
        #     epochs = 32

        epochs = 3
        patience = 2

        callbacks = [
            tf.keras.callbacks.EarlyStopping(monitor='val_loss',
                                             patience=patience)
        ]

        self._model.fit(
            train_x,
            ohe2cat(train_y),
            epochs=epochs,
            callbacks=callbacks,
            validation_data=(val_x, ohe2cat(val_y)),
            verbose=1,  # Logs once per epoch.
            batch_size=32,
            shuffle=True)
コード例 #6
0
 def score(self, x_train, y_train):
     return self._model.score(x_train, ohe2cat(y_train))
コード例 #7
0
 def fit(self, x_train, y_train, *args, **kwargs):
     self._model.fit(x_train, ohe2cat(y_train))