Skip to content

Question abou sub graph #28

@KwankiAhn

Description

@KwankiAhn

Hello, I'm a newbie with GNN and interested in Recommender system using Graphs.
Thanksfully I found a nice paper IGMC.

I 'm trying to understand 'generating sub graph' of this code,
What I was doing was:

  1. generate csr with example picture of rating

row = np.array([0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 6])
col = np.array([0, 1, 2, 4, 8, 4, 6, 7, 1, 3, 4, 6, 0, 6, 7, 8, 2, 3, 5, 7, 9, 1, 3, 5, 8, 0, 2, 5, 7, 9])
rat = np.array([1, 2, 5, 2, 4, 4, 5, 2, 1, 4, 3, 5, 5, 5, 1, 2, 1, 2, 5, 5, 4, 1, 4, 4, 1, 5, 4, 3, 2, 5])
rat = rat - 1  # value to index
ACsr = ssp.csr_matrix((rat, (row, col)))
※ these values are just same with picture of your example rating table.

(<7x10 sparse matrix of type ''
 	with 30 stored elements in Compressed Sparse Row format>,
 array([[0, 1, 4, 0, 1, 0, 0, 0, 3, 0],
        [0, 0, 0, 0, 3, 0, 4, 1, 0, 0],
        [0, 0, 0, 3, 2, 0, 4, 0, 0, 0],
        [4, 0, 0, 0, 0, 0, 4, 0, 1, 0],
        [0, 0, 0, 1, 0, 4, 0, 4, 0, 3],
        [0, 0, 0, 3, 0, 3, 0, 0, 0, 0],
        [4, 0, 3, 0, 0, 2, 0, 1, 0, 4]]))
  1. Then I get a batch sample
  • dataset_class = 'MyDynamicDataset'

Batch(x=[120, 4], edge_index=[2, 112], y=[30], edge_type=[112], batch=[120], ptr=[31])

edge_index (2, 116)
y (30,)
edge_type (116,)

edge_index [[  1   0   2   3   4   7   9   8  10  11  13  12  14  15  17  16  18  19
   21  20  22  23  25  24  26  27  29  28  30  31  33  32  34  35  37  36
   38  39  41  40  42  43  45  44  46  47  49  49  50  51  53  53  54  55
   57  56  58  59  65  64  66  67  69  68  70  71  73  72  74  75  77  76
   78  79  81  80  81  82  83  83  85  85  86  87  89  88  89  90  91  91
   93  94  97  96  98  99 101 100 102 103 104 105 107 107 109 108 110 111
  112 115 117 116 117 118 119 119]
 [  2   3   1   0   7   4  10  11   9   8  14  15  13  12  18  19  17  16
   22  23  21  20  26  27  25  24  30  31  29  28  34  35  33  32  38  39
   37  36  42  43  41  40  46  47  45  44  50  51  49  49  54  55  53  53
   58  59  57  56  66  67  65  64  70  71  69  68  74  75  73  72  78  79
   77  76  82  83  83  81  80  81  86  87  85  85  90  91  91  89  88  89
   94  93  98  99  97  96 102 103 101 100 107 107 104 105 110 111 109 108
  115 112 118 119 119 117 116 117]]
y [1. 2. 5. 2. 4. 4. 5. 2. 1. 4. 3. 5. 5. 5. 1. 2. 1. 2. 5. 5. 4. 1. 4. 4.
 1. 5. 4. 3. 2. 5.]
edge_type [3 3 3 3 3 3 2 0 2 0 2 0 2 0 0 0 0 0 1 0 1 0 3 2 3 2 0 3 0 3 0 2 0 2 0 1 0
 1 0 2 0 2 3 2 3 2 3 0 3 0 3 0 3 0 3 3 3 3 3 3 3 3 2 2 2 2 1 0 1 0 0 0 0 0
 3 3 0 3 3 0 0 2 0 2 0 2 3 0 2 3 1 1 2 2 2 2 3 3 3 3 3 2 3 2 3 3 3 3 1 1 2
 0 3 2 0 3]
ADJ (120, 120) [[0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0]
 [0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0]
 [0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0]
 [4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  0 0 0 0 0 0 0 0 0 0 0 0]

Can you provide how ADJ is acquired ?

  • rating was 30 originally, but we got edge_index : (2, 116), edge_type (116,)
  • what these are meaning ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions