Compared to traditional inter-membrane spacers, profiled ion exchange membranes significantly improve the energy harvesting performance of reverse electrodialysis (RED). Here computational fluid dynamics is employed to generate data regarding the flow and mass transfer characteristics and performance index under different profiled membrane microstructures. Data-driven deep learning models are constructed for microstructure shape generation, physics field prediction, and performance forecasting. Results show that the microstructure shape generation via the Bezier generative adversarial network, the physical field prediction via conditional generative adversarial network for the velocity field and the performance prediction via multi-layer perceptron for power number and Sherwood number achieves satisfied accuracy, respectively. The gradient descent algorithm is utilized to optimize the microstructure shape achieving higher mass transfer performance and lower pump power consumption. Compared to the traditional straight ridge channel, the optimized microstructure channel exhibits a reduction of 18.85 % in the power number and an increase of 41.00 % in the Sherwood number, rendering significantly boosted performance.