コード例 #1
0
        public static Tensor GraphConv_func(
            Tensor features,
            Tensor A,
            int output_units      = 64,
            Activation activation = null,
            Tensorflow.Keras.Layers.Dense layer = null,
            bool building = false
            )
        {
            var    dot = tf.batch_matmul(A, features);
            Tensor res;

            if (building)
            {
                return(layer.Apply(features));
            }
            if (layer is null)
            {
                res = keras.layers.Dense(output_units, activation: activation).Apply(dot);
            }
            else
            {
                res = batch_dense(dot, layer);
            }
            return(res);
        }
コード例 #2
0
        public static Tensor batch_dense(Tensor inputs, Tensorflow.Keras.Layers.Dense layer)
        {
            var original_shape = inputs.shape;
            var all_results    = new List <Tensor>();

            foreach (Tensor item in tf.split(inputs, original_shape[1], -2))
            {
                var reshape = tf.reshape(item, (-1, original_shape[2]));
                all_results.append(layer.Apply(reshape));
            }
            return(tf.transpose(tf.stack(all_results), (1, 0, 2)));
        }