def setUp(self): super(TestOnDenseGrid, self).setUp() sparse_grid_context = nql_test_lib.make_grid() context = nql.NeuralQueryContext() # copy the grid but densify some of it context.declare_relation('n', 'place_t', 'place_t') context.declare_relation('s', 'place_t', 'place_t') context.declare_relation('e', 'place_t', 'place_t') context.declare_relation('w', 'place_t', 'place_t') context.declare_relation('color', 'place_t', 'color_t', dense=True) context.declare_relation('distance_to', 'place_t', 'corner_t') # copy the type definitions for type_name in sparse_grid_context.get_type_names(): entity_list = [ sparse_grid_context.get_entity_name(i, type_name) for i in range(sparse_grid_context.get_max_id(type_name)) ] context.extend_type(type_name, entity_list) # copy the data over for r in sparse_grid_context.get_relation_names(): m = sparse_grid_context.get_initial_value(r) if context.is_dense(r): context.set_initial_value(r, m.todense()) else: context.set_initial_value(r, m) self.context = context self.session = tf.Session()
def setUp(self): super(TestOnGrid, self).setUp() self.context = nql_test_lib.make_grid() self.session = tf.Session()