def input_fn(labeled: DataSet, unlabeled: DataSet, labeled_size, unlabeled_size): input_dict = {} # labeled data labeled = labeled.get_batch(labeled_size) input_dict['labeled_inputs'] = tf.constant(np.array(labeled.inputs())) input_dict['labeled_sequence_length'] = tf.constant(labeled.lengths()) input_dict['labeled_mask'] = tf.constant(labeled.masks()) labels = tf.constant(labeled.labels()) # unlabeled data unlabeled = unlabeled.get_batch(unlabeled_size) input_dict['unlabeled_inputs'] = tf.constant( np.array(unlabeled.inputs())) input_dict['unlabeled_sequence_length'] = tf.constant( unlabeled.lengths()) input_dict['unlabeled_mask'] = tf.constant(unlabeled.masks()) return input_dict, labels
def input_fn(data_set: DataSet, size): input_dict = {} # labeled data data_set = data_set.get_batch(size) input_dict['inputs'] = tf.constant(np.array(data_set.inputs())) input_dict['sequence_length'] = tf.constant(data_set.lengths()) input_dict['mask'] = tf.constant(data_set.masks()) labels = tf.constant(data_set.labels()) return input_dict, labels
def input_fn(labeled: DataSet, unlabeled: DataSet = None, size: int = BATCH_SIZE): input_dict = { } if unlabeled is not None and unlabeled.size() == 0: unlabeled = None # labeled data labeled = labeled.get_batch(size) input_dict['labeled_inputs'] = tf.constant(np.array(labeled.inputs())) input_dict['labeled_sequence_length'] = tf.constant(labeled.lengths()) input_dict['labeled_mask'] = tf.constant(labeled.masks()) labels = tf.constant(labeled.labels()) # unlabeled data unlabeled = unlabeled is None and labeled or unlabeled.get_batch(labeled.size()) input_dict['unlabeled_inputs'] = tf.constant(np.array(unlabeled.inputs())) input_dict['unlabeled_sequence_length'] = tf.constant(unlabeled.lengths()) input_dict['unlabeled_mask'] = tf.constant(unlabeled.masks()) input_dict['unlabeled_size'] = tf.constant(unlabeled.size()) input_dict['unlabeled_target'] = tf.constant(unlabeled.labels()) return input_dict, labels