To predict the evolution of wave spectrum in the real ocean, a machine learning framework is developed by training a long short-term memory (LSTM) neural network on a physics-based third-generation wave model (Simulating WAve Nearshore (SWAN)). Considering the realistic ocean waves are usually mixtures of windsea and swells, the wave spectrum is partitioned using a watershed algorithm, such that the windsea and swells are analyzed and predicted separately. Four parameters are selected to capture the wave spectrum of each system, including the significant wave height Hs, peaked wave period Tp, mean propagation direction θm, and directional spreading width . The results demonstrate that the LSTM neural network can achieve accurate prediction of wave condition, the mean absolute error percentage (MAEPs) of 1-h prediction is less than 5.9%, 3.3%, 3.5%, and 3.3% for Hs, Tp, θm, and , respectively, and accurate prediction of wave spectra is achieved. Even for the 10-h prediction, satisfactory results are obtained, e.g., the MAEP of Hs is less than 15.5%. The effects of output size (i.e., prediction duration), input data size (i.e., number of delays), as well as different combinations of input features on predictions of wave conditions are examined.