Beispiel #1
0
    def tf_signature(self):
        """
        Adjacency matrix has shape [batch, n_nodes, n_nodes]
        Node features have shape [batch, n_nodes, n_node_features]
        Edge features have shape [batch, n_nodes, n_nodes, n_edge_features]
        Labels have shape [batch, n_labels]
        """
        signature = self.signature
        for k in signature:
            signature[k]["shape"] = prepend_none(signature[k]["shape"])
        if "x" in signature and self.mask:
            # In case we have a mask, the mask is concatenated to the features
            signature["x"]["shape"] = signature["x"]["shape"][:-1] + (
                signature["x"]["shape"][-1] + 1, )
        if "a" in signature:
            # Adjacency matrix in batch mode is dense
            signature["a"]["spec"] = tf.TensorSpec
        if "e" in signature:
            # Edge attributes have an extra None dimension in batch mode
            signature["e"]["shape"] = prepend_none(signature["e"]["shape"])
        if "y" in signature and self.node_level:
            # Node labels have an extra None dimension
            signature["y"]["shape"] = prepend_none(signature["y"]["shape"])

        return to_tf_signature(signature)
Beispiel #2
0
 def tf_signature(self):
     """
     Adjacency matrix has shape [n_nodes, n_nodes]
     Node features have shape [n_nodes, n_node_features]
     Edge features have shape [n_edges, n_node_features]
     Targets have shape [..., n_labels]
     """
     signature = self.dataset.signature
     return to_tf_signature(signature)
Beispiel #3
0
    def tf_signature(self):
        """
        Returns the signature of the collated batches using the tf.TypeSpec system.
        By default, the signature is that of the dataset (`dataset.signature`):

            - Adjacency matrix has shape `[n_nodes, n_nodes]`
            - Node features have shape `[n_nodes, n_node_features]`
            - Edge features have shape `[n_edges, n_node_features]`
            - Targets have shape `[..., n_labels]`
        """
        signature = self.dataset.signature
        return to_tf_signature(signature)
Beispiel #4
0
    def tf_signature(self):
        signature = self.dataset.signature
        for k in signature:
            signature[k]['shape'] = prepend_none(signature[k]['shape'])
        if 'a' in signature:
            # Adjacency matrix in batch mode is dense
            signature['a']['spec'] = tf.TensorSpec
        if 'e' in signature:
            # Edge attributes have an extra None dimension in batch mode
            signature['e']['shape'] = prepend_none(signature['e']['shape'])

        return to_tf_signature(signature)
Beispiel #5
0
    def tf_signature(self):
        """
        Adjacency matrix has shape [n_nodes, n_nodes]
        Node features have shape [batch, n_nodes, n_node_features]
        Edge features have shape [batch, n_edges, n_edge_features]
        Targets have shape [batch, ..., n_labels]
        """
        signature = self.dataset.signature
        for k in ["x", "e", "y"]:
            if k in signature:
                signature[k]["shape"] = prepend_none(signature[k]["shape"])

        return to_tf_signature(signature)
Beispiel #6
0
    def tf_signature(self):
        signature = self.dataset.signature
        if 'y' in signature:
            if not self.node_level:
                signature['y']['shape'] = prepend_none(signature['y']['shape'])
        if 'a' in signature:
            signature['a']['spec'] = tf.SparseTensorSpec

        signature['i'] = dict()
        signature['i']['spec'] = tf.TensorSpec
        signature['i']['shape'] = (None,)
        signature['i']['dtype'] = tf.as_dtype(tf.int64)

        return to_tf_signature(signature)
Beispiel #7
0
    def tf_signature(self):
        """
        Adjacency matrix has shape [batch, n_nodes, n_nodes]
        Node features have shape [batch, n_nodes, n_node_features]
        Edge features have shape [batch, n_nodes, n_nodes, n_edge_features]
        Targets have shape [batch, ..., n_labels]
        """
        signature = self.dataset.signature
        for k in signature:
            signature[k]["shape"] = prepend_none(signature[k]["shape"])
        if "a" in signature:
            # Adjacency matrix in batch mode is dense
            signature["a"]["spec"] = tf.TensorSpec
        if "e" in signature:
            # Edge attributes have an extra None dimension in batch mode
            signature["e"]["shape"] = prepend_none(signature["e"]["shape"])

        return to_tf_signature(signature)
Beispiel #8
0
    def tf_signature(self):
        """
        Adjacency matrix has shape [n_nodes, n_nodes]
        Node features have shape [batch, n_nodes, n_node_features]
        Edge features have shape [batch, n_edges, n_edge_features]
        Targets have shape [batch, ..., n_labels]
        """
        signature = self.dataset.signature
        for k in ["x", "e", "y"]:
            if k in signature:
                signature[k]["shape"] = prepend_none(signature[k]["shape"])

        signature["a"] = dict()
        signature["a"]["spec"] = get_spec(self.dataset.a)
        signature["a"]["shape"] = (None, None)
        signature["a"]["dtype"] = tf.as_dtype(self.dataset.a.dtype)

        return to_tf_signature(signature)
Beispiel #9
0
    def tf_signature(self):
        """
        Adjacency matrix has shape [n_nodes, n_nodes]
        Node features have shape [n_nodes, n_node_features]
        Edge features have shape [n_edges, n_edge_features]
        Targets have shape [..., n_labels]
        """
        signature = self.dataset.signature
        if "y" in signature:
            signature["y"]["shape"] = prepend_none(signature["y"]["shape"])
        if "a" in signature:
            signature["a"]["spec"] = tf.SparseTensorSpec

        signature["i"] = dict()
        signature["i"]["spec"] = tf.TensorSpec
        signature["i"]["shape"] = (None, )
        signature["i"]["dtype"] = tf.as_dtype(tf.int64)

        return to_tf_signature(signature)
Beispiel #10
0
 def tf_signature(self):
     signature = self.dataset.signature
     return to_tf_signature(signature)