The experimental optimization of a two-qubit controlled-Z (CZ) gate is realized following two different data-driven gradient ascent pulse engineering (GRAPE) protocols in the aim of optimizing the gate operator and the output quantum state, respectively. For both GRAPE protocols, the key computation of gradients utilizes mixed information of the input Z-control pulse and the experimental measurement. With an imperfect initial pulse in a flattop waveform, our experimental implementation shows that the CZ gate is quickly improved and the gate fidelities subject to the two optimized pulses are around 99%. Our experimental study confirms the applicability of the data-driven GRAPE protocols in the problem of the gate optimization.