# Internal Flow Prediction in Arbitrary Shaped Channel Using Stream-Wise Bidirectional LSTM
## 2 Methodology
### Stream-Wise Bidirectional LSTM  
The deformation of objects in previous internal flow prediction studies only has a small impact on the distribution of field values, and the overall pattern of the field does  
Figure 5: Sample set of target field data. From left to right: (**a**) x-component velocity, (**b**) y-component velocity, (**c**) kinematic pressure, (**d**) all fluid region, (**e**) corner vortex region.  
not change significantly. However, the data generated through the above method undergo significant changes depending on the shape of the entire domain. Therefore, if a fully convolutional neural network is used for inference and training, problems arise.  
To solve the problems of the existing network model, a module was designed based on bidirectional LSTM, which has shown strength in filling in words through context in natural language processing [33]. Generally, when dealing with dynamic data in deep learning, LSTM has been mainly used for time series data learning [34]. However, there have been studies using the concept of bidirectional LSTM for character inference within images in the field of image processing [35; 36] The SB-LSTM module was inspired by this CNN-RNN combined approach.  
The SB-LSTM module was designed to take the compressed latent geometry space as input and produce a feature map that includes the relationships between the forward and backward sequences of the feature space. While an encoder with convolutional layers can contract the input and extract high-level features, it does not include information about the lateral connections between pixels [37]. This means that global features related to the shape and flow direction of the channels are not well preserved in latent space when using only an encoder. To address this, the authors propose using bidirectional LSTM at the latent space to learn the directional relationships between pixels.  
The entire process of the SB-LSTM module is depicted in Figure 6. The latent geometry space of size \(H\times W\times C\), denoting the height, width, and channel, respectively, is first rearranged in the stream-wise direction (along the width axis) through a flattening process. This results in \(W\) divided components, each represented as a 1D matrix of size \(C\times H\). Second, each serial vector \(Z_{i}\) continuously updates the cell state and hidden state of the forward LSTM, which are initialized to zero with a size equal to \(C\times H\), and returns an output \(Z^{\prime}_{f,i}\), where \(i\) denotes the index of each input vector. Consequently, this allows us to obtain the output \(Z^{\prime}_{f,i}\), which contains information on the feature spaces sequentially passing along the flow direction to the \(i\)-th point. Similarly, \(Z_{i}\) is used to update the cell and hidden states of the backward LSTM from the outlet to the inlet direction, outputting \(Z^{\prime}_{b,i}\). Third, the forward and backward hidden states at the \(i\)-th latent position are combined to create a set of new serial vectors containing the expected lateral relation along all separated areas. Since vectors from the forward and backward LSTM are aggregated together, the length of the output vector becomes \(2C\times H\). Finally, the output is repeated \(H\) times in the vertical direction in order to share the same information among the latent spaces that are involved in the flattening process. In summary, the proposed SB-LSTM module addresses the local limitations of the latent space in the existing encoder by generating global features through bidirectional LSTM. This makes it suitable for the analysis of internal flows on arbitrary channel shapes. The effect of the module is thoroughly analyzed in Section 3.