The cost of obtaining a complete porosity value using traditional coring methods is relatively high, and as the drilling depth increases, the difficulty of obtaining the porosity value also increases. Nowadays, the prediction of fine reservoir parameters for oil and gas exploration is becoming more and more important. Therefore, high-efficiency and low-cost prediction of porosity based on logging data is necessary. We have developed a machine-learning method based on the traditional long short-term memory (LSTM) model, called multilayer LSTM (MLSTM), to perform the porosity prediction task. We used three different wells in a block in southern China for the prediction task, including a training well and two test wells. One test well has the same logging data type as the training well, whereas the other test well differs from the training well in the logging depth and parameter types. Two different types of test data sets are used to detect the generalization ability of the network. A set of data was used to train the MLSTM network, and the hyperparameters of the network were adjusted through experimental accuracy feedback. We also tested the performance of the network using two sets of log data from different regions, including generalization and sensitivity of the network. During the training phase of the porosity prediction model, the developed MLSTM establishes a minimized objective function, uses the Adam optimization algorithm to update the weight of the network, and adjusts the network hyperparameters to select the best target according to the feedback of the network accuracy. Compared with conventional sequence neural networks, such as the gated recurrent unit and recurrent neural network, the logging data experiments show that MLSTM has better robustness and accuracy in depth sequence prediction. Especially, the porosity value at the depth inflection point can be better predicted when the trend of the depth sequence was predicted. This framework is expected to reduce the porosity prediction errors when data are insufficient and log depths are different.