You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_gat_model.py 1.6 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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."""
  16. import numpy as np
  17. import mindspore.nn as nn
  18. import mindspore.context as context
  19. from mindspore import Tensor
  20. from mindspore.common.api import _executor
  21. from gat import GAT
  22. context.set_context(mode=context.GRAPH_MODE)
  23. def test_GAT():
  24. ft_sizes = 1433
  25. num_class = 7
  26. num_nodes = 2708
  27. hid_units = [8]
  28. n_heads = [8, 1]
  29. activation = nn.ELU()
  30. residual = False
  31. input_data = Tensor(
  32. np.array(np.random.rand(1, 2708, 1433), dtype=np.float32))
  33. biases = Tensor(np.array(np.random.rand(1, 2708, 2708), dtype=np.float32))
  34. net = GAT(ft_sizes,
  35. num_class,
  36. num_nodes,
  37. hidden_units=hid_units,
  38. num_heads=n_heads,
  39. attn_drop=0.6,
  40. ftr_drop=0.6,
  41. activation=activation,
  42. residual=residual)
  43. _executor.compile(net, input_data, biases)