This paper presents a self-supervised machine learning approach for cognitive reconfiguration in a Hyper-X-like flexible-bandwidth optical interconnect architecture. The proposed approach makes use of a clustering algorithm to learn the traffic patterns from historical traces. A heuristic algorithm is developed for optimizing the connectivity graph for each identified traffic pattern. Further, to mitigate the scalability issue induced by frequent clustering operations, we parameterize the learned traffic patterns by a deep neural network classifier. The classifier is trained offline by supervised learning to enable classification of traffic matrices during online operations, thereby facilitating cognitive reconfiguration decision making. Simulation results show that compared with a static all-toall interconnection, the proposed approach can improve throughput by up to 1.76× while reducing end-to-end packet latency and flow completion time by up to 2.8× and 25×, respectively.