def Or(*wffs): if len(wffs) == 0: result = tf.constant(0.0) result.doms = [] else: cross_wffs, _ = cross_args(wffs) label = "_OR_".join([wff.name.split(":")[0] for wff in wffs]) result = tf.identity(F_Or(cross_wffs), name=label) result.doms = cross_wffs.doms return result
def pred(*args): global BIAS crossed_args, list_of_args_in_crossed_args = cross_args(args) result = apply_pred(*list_of_args_in_crossed_args) if crossed_args.doms != []: result = tf.reshape( result, tf.concat([tf.shape(crossed_args)[:-1], [1]], axis=0)) else: result = tf.reshape(result, (1, )) result.doms = crossed_args.doms BIAS = tf.divide(BIAS + .5 - tf.reduce_mean(result), 2) * BIAS_factor return result
def fun(*args): crossed_args, list_of_args_in_crossed_args = cross_args(args) result = apply_fun(*list_of_args_in_crossed_args) if crossed_args.doms != []: result = tf.reshape( result, tf.concat([tf.shape(crossed_args)[:-1], tf.shape(result)[-1:]], axis=0)) else: result = tf.reshape(result, (output_shape_spec, )) result.doms = crossed_args.doms return result
def function_grounding(*args): crossed_args, list_of_args_in_crossed_args = cross_args(args) result = self.func_definition(*list_of_args_in_crossed_args) if crossed_args.doms != []: result = tf.reshape( result, tf.concat( [tf.shape(crossed_args)[:-1], tf.shape(result)[-1:]], axis=0)) else: result = tf.reshape(result, (self.output_shape_spec, )) result.doms = crossed_args.doms return result
def predicate_grounding(*args): # global BIAS crossed_args, list_of_args_in_crossed_args = cross_args(args) result = self.grounding_definition(*list_of_args_in_crossed_args) if crossed_args.doms != []: result = tf.reshape( result, tf.concat([tf.shape(crossed_args)[:-1], [1]], axis=0)) else: result = tf.reshape(result, (1, )) result.doms = crossed_args.doms BIAS = get_bias() update_bias( tf.divide(BIAS + .5 - tf.reduce_mean(result), 2) * BIAS_factor) return result