Due to the randomness, complexity, many influencing factors, and dominant time series of wind and wave data, traditional prediction models have great prediction difficulty and low prediction accuracy. In response, this study proposes an ocean wave prediction model combining the attention mechanism of the random forest with the bidirectional long short-term memory (BiLSTM) neural network. The model optimizes the inputs and can predict ocean waves with past and future data to improve the prediction accuracy on the wave height. It uses the random forest to filter and optimize the input variables and thereby reduce the network complexity. Then, the attention mechanism is combined with the BiLSTM neural network to build a prediction model, which is subsequently verified on actual data. The results show that compared with the BP, LSTM, and BiLSTM models, the RF-BiLSTM model has higher prediction accuracy and fitting degree and thereby has good application value in the prediction of ocean wave values.