Generate set intersections. Yields: a tuple with one data for each task
()
| 825 | raise ValueError('mode not recognized: %s' % mode) |
| 826 | |
| 827 | def mixture_generator(): |
| 828 | """Generate set intersections. |
| 829 | |
| 830 | Yields: |
| 831 | a tuple with one data for each task |
| 832 | """ |
| 833 | data_per_epoch = DATA_PER_EPOCH if n_take == -1 else n_take |
| 834 | for _ in range(data_per_epoch * epochs): |
| 835 | # Get model results for the task of membership. |
| 836 | m_objs = set_members[np.random.randint(len(set_members))] |
| 837 | m_padded_ent_ids, m_labels = self.gen_one_membership_data(m_objs) |
| 838 | |
| 839 | # Get model results for the task of intersection and union. |
| 840 | p_set1, p_set2 = set_pairs[np.random.randint(len(set_pairs))] |
| 841 | p_candidate_set1, p_candidate_set2, p_union_labels = \ |
| 842 | self.gen_one_pair_data('union', p_set1, p_set2) |
| 843 | p_intersection_labels = np.minimum(p_candidate_set1, p_candidate_set2) |
| 844 | |
| 845 | # Get model results for the task of set_follows. |
| 846 | f_subj_factids, f_rel_factids = set_follows[np.random.randint( |
| 847 | len(set_follows))] |
| 848 | f_candidate_set1, f_candidate_set2, f_labels = self.gen_one_follow_data( |
| 849 | f_subj_factids, f_rel_factids) |
| 850 | |
| 851 | yield (m_padded_ent_ids, m_labels, p_candidate_set1, p_candidate_set2, |
| 852 | p_union_labels, p_intersection_labels, f_candidate_set1, |
| 853 | f_candidate_set2, f_labels), 0.0 |
| 854 | |
| 855 | def input_fn(): |
| 856 | """Create tf.dataset for estimator. |
nothing calls this directly
no test coverage detected