Python tensorflow.keras.utils.Progbar() Examples
The following are 4
code examples of tensorflow.keras.utils.Progbar().
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
tensorflow.keras.utils
, or try the search function
.
Example #1
Source File: sequential.py From tf-encrypted with Apache License 2.0 | 6 votes |
def fit(self, x, y, epochs=1, steps_per_epoch=1): """Trains the model for a given number of epochs (iterations on a dataset). Arguments: x: Private tensor of training data y: Private tensor of target (label) data epochs: Integer. Number of epochs to train the model. steps_per_epoch: Integer. Total number of steps (batches of samples) before declaring one epoch finished and starting the next epoch. """ assert isinstance(x, PondPrivateTensor), type(x) assert isinstance(y, PondPrivateTensor), type(y) # Initialize variables before starting to train sess = KE.get_session() sess.run(tf.global_variables_initializer()) for e in range(epochs): print("Epoch {}/{}".format(e + 1, epochs)) batch_size = x.shape.as_list()[0] progbar = utils.Progbar(batch_size * steps_per_epoch) for _ in range(steps_per_epoch): self.fit_batch(x, y) progbar.add(batch_size, values=[("loss", self._current_loss)])
Example #2
Source File: svd.py From Recommender-Systems-Samples with MIT License | 5 votes |
def run_train(self, x, y, epoches, batch_size, val_data): train_gen = BatchGenerator(x, y, batch_size=batch_size) steps_per_epoch = np.ceil(train_gen.length / batch_size).astype(int) self.sess.run(tf.global_variables_initializer()) for i in range (1, epoches+1): print('Epoch {} / {}'.format(i, epoches)) pbar = utils.Progbar(steps_per_epoch) for step, batch in enumerate(train_gen.next(), 1): users = batch[0][:, 0] items = batch[0][:, 1] ratings = batch[1] self.sess.run(self.optimizer, feed_dict={ self.users: users, self.items: items, self.ratings: ratings}) pred = self.predict(batch[0]) update_values = [ ('rmse', rmse(ratings, pred)), ('mae', mae(ratings, pred))] if(val_data is not None and step == steps_per_epoch): valid_x, valid_y = val_data valid_pred = self.predict(valid_x) update_values += [ ('val_rmse', rmse(valid_y, valid_pred)), ('val_mae', mae(valid_y, valid_pred))] pbar.update(step, value=update_values, force=(step==steps_per_epoch))
Example #3
Source File: svd.py From Recommender-Systems-Samples with MIT License | 5 votes |
def run_train(self, x, y, epoches, batch_size, val_data): train_gen = BatchGenerator(x, y, batch_size=batch_size) steps_per_epoch = np.ceil(train_gen.length / batch_size).astype(int) self.sess.run(tf.global_variables_initializer()) for i in range (1, epoches+1): print('Epoch {} / {}'.format(i, epoches)) pbar = utils.Progbar(steps_per_epoch) print('stpes_per_epoch', steps_per_epoch) for step, batch in enumerate(train_gen.next(), start=1): users = batch[0][:, 0] items = batch[0][:, 1] ratings = batch[1] self.sess.run(self.optimizer, feed_dict={ self.users: users, self.items: items, self.ratings: ratings}) pred = self.predict(batch[0]) update_values = [ ('rmse', rmse(ratings, pred)), ('mae', mae(ratings, pred))] if(val_data is not None and step == steps_per_epoch): valid_x, valid_y = val_data valid_pred = self.predict(valid_x) update_values += [ ('val_rmse', rmse(valid_y, valid_pred)), ('val_mae', mae(valid_y, valid_pred))] pbar.update(step, values=update_values)
Example #4
Source File: svd.py From tf-recsys with MIT License | 4 votes |
def _run_train(self, x, y, epochs, batch_size, validation_data): train_gen = BatchGenerator(x, y, batch_size) steps_per_epoch = np.ceil(train_gen.length / batch_size).astype(int) self._sess.run(tf.global_variables_initializer()) for e in range(1, epochs + 1): print('Epoch {}/{}'.format(e, epochs)) pbar = utils.Progbar(steps_per_epoch) for step, batch in enumerate(train_gen.next(), 1): users = batch[0][:, 0] items = batch[0][:, 1] ratings = batch[1] self._sess.run( self._optimizer, feed_dict={ self._users: users, self._items: items, self._ratings: ratings }) pred = self.predict(batch[0]) update_values = [ ('rmse', rmse(ratings, pred)), ('mae', mae(ratings, pred)) ] if validation_data is not None and step == steps_per_epoch: valid_x, valid_y = validation_data valid_pred = self.predict(valid_x) update_values += [ ('val_rmse', rmse(valid_y, valid_pred)), ('val_mae', mae(valid_y, valid_pred)) ] pbar.update(step, values=update_values, force=(step == steps_per_epoch))