def train(self, train_mode, training_data_filepath, model_dirpath, batch_size, embedding_size, num_neg_samples, learning_rate, window_size, num_epochs, sampling_rate, p_num_threads, t_num_threads, shuffling_buffer_size, save_summary_steps, save_checkpoints_steps, keep_checkpoint_max, log_step_count_steps, debug, debug_port, xla):
    'Train Word2Vec.'
    if (self.vocab_size == 1):
        raise Exception('You need to build or load a vocabulary before training word2vec')
    if (train_mode not in ('cbow', 'skipgram')):
        raise Exception("Unsupported train_mode '{}'".format(train_mode))
    sess_config = tf.compat.v1.ConfigProto(log_device_placement=True)
    sess_config.intra_op_parallelism_threads = t_num_threads
    sess_config.inter_op_parallelism_threads = t_num_threads
    run_config = tf.estimator.RunConfig(session_config=sess_config, save_summary_steps=save_summary_steps, save_checkpoints_steps=save_checkpoints_steps, keep_checkpoint_max=keep_checkpoint_max, log_step_count_steps=log_step_count_steps)
    estimator = tf.estimator.Estimator(model_fn=w2v_model.model, model_dir=model_dirpath, config=run_config, params={'mode': train_mode, 'vocab_size': self.vocab_size, 'batch_size': batch_size, 'embedding_size': embedding_size, 'num_neg_samples': num_neg_samples, 'learning_rate': learning_rate, 'words': self._words, 'p_num_threads': p_num_threads, 'xla': xla, 'men': MEN(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'MEN_dataset_natural_form_full'))})
    tf.compat.v1.disable_eager_execution()
    if debug:
        raise Exception('Unsupported parameter: waiting for the TF team to release v2 equivalents for TensorBoardDebugHook')
    hooks = [tf.estimator.ProfilerHook(save_steps=save_summary_steps, show_dataflow=True, show_memory=True, output_dir=model_dirpath)]
    estimator.train(input_fn=(lambda : datasets_utils.get_w2v_train_dataset(training_data_filepath, train_mode, self._words, self._counts, self._total_count, window_size, sampling_rate, batch_size, num_epochs, p_num_threads, shuffling_buffer_size)), hooks=hooks)
Train Word2Vec.
def train(self, train_mode, training_data_filepath, model_dirpath, batch_size, embedding_size, num_neg_samples, learning_rate, window_size, num_epochs, sampling_rate, p_num_threads, t_num_threads, shuffling_buffer_size, save_summary_steps, save_checkpoints_steps, keep_checkpoint_max, log_step_count_steps, debug, debug_port, xla):
    
    if (self.vocab_size == 1):
        raise Exception('You need to build or load a vocabulary before training word2vec')
    if (train_mode not in ('cbow', 'skipgram')):
        raise Exception("Unsupported train_mode '{}'".format(train_mode))
    sess_config = tf.compat.v1.ConfigProto(log_device_placement=True)
    sess_config.intra_op_parallelism_threads = t_num_threads
    sess_config.inter_op_parallelism_threads = t_num_threads
    run_config = tf.estimator.RunConfig(session_config=sess_config, save_summary_steps=save_summary_steps, save_checkpoints_steps=save_checkpoints_steps, keep_checkpoint_max=keep_checkpoint_max, log_step_count_steps=log_step_count_steps)
    estimator = tf.estimator.Estimator(model_fn=w2v_model.model, model_dir=model_dirpath, config=run_config, params={'mode': train_mode, 'vocab_size': self.vocab_size, 'batch_size': batch_size, 'embedding_size': embedding_size, 'num_neg_samples': num_neg_samples, 'learning_rate': learning_rate, 'words': self._words, 'p_num_threads': p_num_threads, 'xla': xla, 'men': MEN(os.path.join(os.path.dirname(os.path.dirname(__file__)), 'resources', 'MEN_dataset_natural_form_full'))})
    tf.compat.v1.disable_eager_execution()
    if debug:
        raise Exception('Unsupported parameter: waiting for the TF team to release v2 equivalents for TensorBoardDebugHook')
    hooks = [tf.estimator.ProfilerHook(save_steps=save_summary_steps, show_dataflow=True, show_memory=True, output_dir=model_dirpath)]
    estimator.train(input_fn=(lambda : datasets_utils.get_w2v_train_dataset(training_data_filepath, train_mode, self._words, self._counts, self._total_count, window_size, sampling_rate, batch_size, num_epochs, p_num_threads, shuffling_buffer_size)), hooks=hooks)