class_docstr: The MNIST images used as node features for a grid graph, as described by
  [Defferrard et al. (2016)](https://arxiv.org/abs/1606.09375).
  
  This dataset is a graph signal classification task, where graphs are
  represented in mixed mode: one adjacency matrix, many instances of node
  features.
  
  For efficiency, the adjacency matrix is stored in a special attribute of the
  dataset and the Graphs only contain the node features.
  You can access the adjacency matrix via the `a` attribute.
  
  The node features of each graph are the MNIST digits vectorized and rescaled
  to [0, 1].
  Two nodes are connected if they are neighbours on the grid.
  Labels represent the MNIST class associated to each sample.
  
  **Note:** the last 10000 samples are the default test set of the MNIST
  dataset.
  
  **Arguments**
  
  - `p_flip`: if >0, then edges are randomly flipped from 0 to 1 or vice versa
  with that probability.
  - `k`: number of neighbours of each node.
class_docstr_tok: ["The","MNIST","images","used","as","node","features","for","a","grid","graph",",","as","described","by","[","Defferrard","et","al",".","(","2016",")","]","(","https",":","\/\/arxiv.org\/abs\/1606.09375",")",".","This","dataset","is","a","graph","signal","classification","task",",","where","graphs","are","represented","in","mixed","mode",":","one","adjacency","matrix",",","many","instances","of","node","features",".","For","efficiency",",","the","adjacency","matrix","is","stored","in","a","special","attribute","of","the","dataset","and","the","Graphs","only","contain","the","node","features",".","You","can","access","the","adjacency","matrix","via","the","`","a","`","attribute",".","The","node","features","of","each","graph","are","the","MNIST","digits","vectorized","and","rescaled","to","[","0",",","1","]",".","Two","nodes","are","connected","if","they","are","neighbours","on","the","grid",".","Labels","represent","the","MNIST","class","associated","to","each","sample",".","*","*","Note",":","*","*","the","last","10000","samples","are","the","default","test","set","of","the","MNIST","dataset",".","*","*","Arguments","*","*","-","`","p_flip","`",":","if",">","0",",","then","edges","are","randomly","flipped","from","0","to","1","or","vice","versa","with","that","probability",".","-","`","k","`",":","number","of","neighbours","of","each","node","."]
code: def __init__(self, p_flip=0.0, k=8, **kwargs):
      self.a = None
      self.k = k
      self.p_flip = p_flip
      super().__init__(**kwargs)
  
file_path: spektral/spektral/datasets/mnist.py
imports: import numpy
  import scipy.sparse
  from sklearn.neighbors import kneighbors_graph
  from tensorflow.keras.datasets import mnist
  from spektral.data import Dataset, Graph
label_desc: Use image node_id 1 to create a new MNIST object from inherited base classes: Dataset with example: obj = MNIST(p_flip, k)