Hello QU,
Can you please tell me if you're using a Series or DAG network? The steps to replace a layer is different for these 2 network types.
For a Series Network, follow steps here --> https://www.mathworks.com/help/nnet/examples/transfer-learning-using-alexnet.html#d119e3782
For DAG follow this --> https://www.mathworks.com/help/nnet/ref/nnet.cnn.layergraph.html?s_tid=doc_ta#d119e84822
Also, is the motivation behind replacing the FC layer with a conv2d is to make the network deeper?