• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2020 Huawei Technologies Co., Ltd
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ============================================================================
15"""test gat model."""
16import numpy as np
17
18import mindspore.nn as nn
19import mindspore.context as context
20from mindspore import Tensor
21from mindspore.common.api import _cell_graph_executor
22from gat import GAT
23
24context.set_context(mode=context.GRAPH_MODE)
25
26
27def test_GAT():
28    ft_sizes = 1433
29    num_class = 7
30    num_nodes = 2708
31    hid_units = [8]
32    n_heads = [8, 1]
33    activation = nn.ELU()
34    residual = False
35    input_data = Tensor(
36        np.array(np.random.rand(1, 2708, 1433), dtype=np.float32))
37    biases = Tensor(np.array(np.random.rand(1, 2708, 2708), dtype=np.float32))
38    net = GAT(ft_sizes,
39              num_class,
40              num_nodes,
41              hidden_units=hid_units,
42              num_heads=n_heads,
43              attn_drop=0.6,
44              ftr_drop=0.6,
45              activation=activation,
46              residual=residual)
47    _cell_graph_executor.compile(net, input_data, biases)
48