A dairy goat behavior recognition method based on discrete cosine transform frequency domain projection

By constructing a CNN-TCN behavior recognition model based on discrete cosine transform frequency domain projection, the problems of insufficient frequency domain feature capture and low training efficiency in the existing technology of dairy goat behavior recognition are solved, and high-precision all-weather automated monitoring and recognition are realized.

CN122290198APending Publication Date: 2026-06-26NORTHWEST A & F UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NORTHWEST A & F UNIV
Filing Date
2026-03-20
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Existing time-domain analysis-based methods for recognizing dairy goat behavior struggle to capture frequency-domain rhythmic features, leading to confusion or misjudgment of rumination and feeding behaviors. Furthermore, these methods suffer from low model training efficiency and low recognition accuracy.

Method used

A CNN-TCN behavior recognition model based on discrete cosine transform frequency domain projection is adopted. Motion data is collected by IMU sensor and combined with video data to construct a feature extraction front-end module, a temporal modeling backbone module and an attention enhancement module. Discrete wavelet transform and discrete cosine transform are used to capture spectral features, so as to achieve efficient parallel feature extraction.

Benefits of technology

It achieves all-weather automated monitoring, significantly reduces the misjudgment rate of similar behaviors, improves recognition accuracy and robustness, and enhances the model's recognition ability in dynamic environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122290198A_ABST
    Figure CN122290198A_ABST
Patent Text Reader

Abstract

This application belongs to the field of intelligent monitoring technology in animal husbandry. This application provides a method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection. The embodiments of this disclosure construct a deep learning model comprising a local feature extraction front-end, a long-term modeling backbone, and a frequency domain attention enhancement layer. The enhancement layer adopts a serial decoupling design: in the first stage, spatial information is aggregated through a channel attention module to dynamically select sensor channels with high signal-to-noise ratios; in the second stage, a spectrum-temporal attention module uses a fixed 1D-DCT basis function as a filter to directly extract multi-band energy distribution features from the feature map, giving the model "frequency perception" capabilities. This design utilizes the energy concentration characteristics of DCT to achieve spectrum feature extraction with zero additional parameters. While reducing computational redundancy, it accurately locks the time boundaries of periodic behaviors such as rumination and steady-state walking, providing an efficient technical means for refined health management of livestock.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of intelligent monitoring technology in animal husbandry, and in particular to a method for recognizing the behavior of dairy goats based on discrete cosine transform frequency domain projection. Background Technology

[0002] With the acceleration of intelligentization in animal husbandry, animal health monitoring and behavior recognition have become important research directions in the field of smart farming. Dairy goat farming is an important part of modern animal husbandry, and the monitoring of abnormal behavior is a core link in reproductive management, directly affecting the reproductive efficiency and economic benefits of farms. Existing behavior recognition methods based on time-domain analysis (such as RNN and LSTM) mainly focus on changes in signal amplitude. However, specific behaviors of livestock (such as rumination and chewing) are characterized by small amplitude but significant frequency features. When faced with such behaviors, existing models often fail to explicitly capture the frequency domain rhythmic features, leading to confusion between rumination and feeding, or misjudging other head behaviors as feeding. To solve these problems, automatic recognition technology based on contact sensors has emerged in recent years. Existing technical solutions typically use inertial sensors worn on the sheep's body (such as the neck, legs, or head) to collect motion data and use specific algorithms to determine the sheep's behavioral state.

[0003] Traditional manual observation methods suffer from low efficiency, high subjectivity, and susceptibility to environmental interference, making them unsuitable for the precision management demands of modern aquaculture. In recent years, with the development of wearable devices and IoT technology, using accelerometers to collect real-time animal movement data and employing artificial intelligence algorithms for behavior recognition has become an important solution.

[0004] However, current popular deep learning methods still have certain limitations, and sequential dependency structures have the following technical limitations: 1. Inflexible data processing: The model relies on a fixed-length time window input, which lacks flexibility when processing variable-length sequences; 2. Low training efficiency: During model training, the training time is long, the convergence speed is slow, and the model size is huge.

[0005] 3. Insufficient ability to identify behavioral stages: When faced with extremely unstable or transient signals lacking obvious periodicity, its feature expression ability may be limited, resulting in low recognition accuracy.

[0006] Therefore, how to design a structure that can extract spatial and temporal features in parallel and improve the model's expressive power and recognition accuracy has become a key issue in current animal behavior recognition research.

[0007] Therefore, it is necessary to improve one or more of the problems existing in the above-mentioned related technical solutions.

[0008] It should be noted that this section is intended to provide background or context for the technical solutions of this disclosure as set forth in the claims. The description herein does not constitute an admission that it is prior art simply because it is included in this section. Summary of the Invention

[0009] The purpose of this disclosure is to provide a method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection, thereby overcoming, to at least some extent, one or more problems caused by the limitations and defects of related technologies.

[0010] According to embodiments of this disclosure, a method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection is provided, including: Motion data is collected by an IMU installed on the body of a dairy goat, and corresponding behavioral video data is collected by a camera device synchronized with the IMU time. The motion data is preprocessed and labeled in conjunction with the behavioral video data to obtain the input sample set, which includes a training set and a test set. Construct a CNN-TCN behavior recognition model; the CNN-TCN behavior recognition model includes a feature extraction front-end module, a temporal modeling backbone module, and an attention enhancement module connected in sequence; The CNN-TCN behavior recognition model is trained and tested using the input sample set to obtain a trained CNN-TCN behavior recognition model; The movement data of the dairy goats to be identified is input into the trained CNN-TCN behavior recognition model, which outputs the corresponding behavior category.

[0011] Furthermore, the preprocessing of motion data includes: A hierarchical random downsampling algorithm was used to standardize all motion data to a frequency of 50Hz. Z-score standardization is performed independently for each sensor channel; Discrete wavelet transform is used for filtering and noise reduction; The sliding window technique sets the window length to 128 sampling points and the sliding step size to 64 sampling points, forming input samples with a 50% overlap rate.

[0012] Furthermore, the feature extraction front-end module consists of alternating layers of 1D-CNN networks and pooling layers; the processing procedure of the feature extraction front-end module is as follows: The 1D-CNN network extracts shallow geometric features and local waveform patterns from the input sample set, and flattens the feature vectors through the Flatten layer to obtain a high-dimensional feature map; Pooling layers reduce the dimensionality of high-dimensional feature maps to obtain initial feature maps.

[0013] Furthermore, in the 1D-CNN network, the operation at the j-th output channel and time step t is as follows:

[0014] in, Let be the local feature output value of the j-th output channel at time step t. It is a linear rectified activation function. For batch normalization, The number of channels for the input data. The size of the one-dimensional convolution kernel. Let k be the learnable weight of the j-th convolutional kernel at position k on the m-th input channel. To represent the input data of the m-th channel at time step t+k, This is the bias term for the j-th convolutional kernel; The high-dimensional feature map is as follows:

[0015] in, For batch size, The number of feature channels, The length is the time dimension.

[0016] Furthermore, the temporal modeling backbone module consists of multiple layers of one-dimensional dilated convolutions; the processing procedure of the temporal modeling backbone module is as follows: The time-series modeling backbone module extracts multi-band energy distribution features from the initial feature map to obtain the input feature map.

[0017] Furthermore, the dilated convolution operation is as follows:

[0018] in, Given one-dimensional time series data as input, For dilated convolution, For filter functions, It is the expansion factor. For the input time series at the offset The value at; The output of the time series modeling backbone module is stabilized through residual connections:

[0019] in, This represents the final output feature map. Represents the initial feature map; This indicates the layer performing the dilated convolution operation.

[0020] Furthermore, the attention enhancement module includes a sequentially connected channel attention submodule and a spectrum-temporal attention submodule; the processing procedure of the attention enhancement module is as follows: The channel attention submodule performs global average pooling and global max pooling along the time dimension on the input feature map, learns the weights of each sensor channel through a shared multilayer perceptron to generate a channel attention map, and generates a refined feature map based on the channel attention map. The spectrum-temporal attention submodule averages the refined feature map to obtain a global temporal view; it uses a pre-defined one-dimensional DCT basis function as an untrainable convolution kernel to capture low-frequency and mid-frequency components in the signal to extract multi-band spectral features; it maps the multi-band spectral features to temporal attention weights through a fully connected layer to perform secondary weighting on the temporal dimension of the feature map; and it introduces residual connections to output the final feature map.

[0021] Furthermore, in the channel attention submodule, spatial information is aggregated along the time dimension L using global average pooling and global max pooling:

[0022] in, For the initial feature map , The length is the time dimension; For global average pooling, This is for global max pooling; The channel attention map is as follows:

[0023] in, This represents the Sigmoid activation function; The refined feature map is as follows:

[0024] in, This represents element-wise multiplication; In the spectrum-temporal attention submodule, the global temporal view is as follows:

[0025] in, Let c be the feature sequence vector of the c-th channel in the feature map at all time steps; The one-dimensional DCT basis functions are:

[0026] in, Let be the value of the DCT basis function of the k-th frequency component at time i; The first K low-frequency and mid-frequency component vectors are extracted through convolution operation:

[0027] in, The intermediate frequency component vector; The time attention weights are:

[0028] in, This is the first learnable weight matrix. This is the second learnable weight matrix; The final feature map is as follows:

[0029] in, This is the feature map after channel attention refinement.

[0030] The technical solutions provided by the embodiments of this disclosure may include the following beneficial effects: In the embodiments of this disclosure, the above-mentioned method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection has the following advantages: First, the method uses contact inertial sensing technology to completely solve the interference of environmental factors such as dim lighting, obstructed vision, and overlapping bodies on the recognition accuracy, thereby realizing all-weather automated monitoring.

[0031] Secondly, this method can effectively distinguish between "standing" and "walking" (differences in leg data), and between "lying down ruminating" and "standing ruminating" (differences in posture angles), significantly reducing the misjudgment rate of similar behaviors.

[0032] Thirdly, a spectrum-temporal attention mechanism based on Discrete Cosine Transform (DCT) is introduced, enabling the model to "see" the fingerprint features of behavior in the frequency domain without requiring any additional learnable parameters. This has a decisive advantage in recognizing highly periodic behaviors, significantly improving the recognition accuracy of such behaviors.

[0033] Fourthly, the Channel Attention (CAM) mechanism can adaptively filter effective information channels and automatically suppress invalid noise generated by body tremors. Specifically, this module can automatically learn to assign high weights to head sensors during "eating" and high weights to leg sensors during "walking," suppressing interference from invalid axes. This improves the model's robustness in dynamic and complex environments.

[0034] Fifthly, the adopted TCN architecture has parallel computing capabilities, resulting in higher training efficiency; and through dilated convolution design, it can cover a longer time window with fewer parameters, effectively capturing long-term subtle behavioral changes in estrus or early stages of disease. Attached Figure Description

[0035] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0036] Figure 1 The diagram illustrates the steps of a dairy goat behavior recognition method based on discrete cosine transform frequency domain projection in an exemplary embodiment of this disclosure. Figure 2 A schematic diagram showing the sensor wearing position in an exemplary embodiment of this disclosure; Figure 3 This illustration shows a comparison of noise reduction before and after in an exemplary embodiment of this disclosure; Figure 4 A framework diagram of the CNN-TCN behavior recognition model in an exemplary embodiment of this disclosure is shown; Figure 5 A structural diagram of the CSTA module in an exemplary embodiment of this disclosure is shown. Detailed Implementation

[0037] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0038] Furthermore, the accompanying drawings are merely illustrative diagrams of embodiments of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities.

[0039] This example implementation provides a method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection. (Reference) Figure 1 As shown, the goat behavior recognition method based on discrete cosine transform frequency domain projection may include: Step S1: Collect motion data by installing an IMU on the body of the dairy goat, and collect corresponding behavioral video data by a camera device synchronized with the IMU time. Step S2: Preprocess the motion data and label it in conjunction with the behavioral video data to obtain the input sample set; wherein, the input sample set includes the training set and the test set; Step S3: Construct the CNN-TCN behavior recognition model; wherein, the CNN-TCN behavior recognition model includes a feature extraction front-end module, a temporal modeling backbone module, and an attention enhancement module connected in sequence; Step S4: Train and test the CNN-TCN behavior recognition model using the input sample set to obtain the trained CNN-TCN behavior recognition model; Step S5: Input the movement data of the dairy goat to be identified into the trained CNN-TCN behavior recognition model and output the corresponding behavior category.

[0040] The above-mentioned method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection has several advantages. Firstly, by employing contact inertial sensing technology, this method completely solves the interference of environmental factors such as dim lighting, obstructed vision, and overlapping bodies on recognition accuracy, thus achieving all-weather automated monitoring.

[0041] Secondly, this method can effectively distinguish between "standing" and "walking" (differences in leg data), and between "lying down ruminating" and "standing ruminating" (differences in posture angles), significantly reducing the misjudgment rate of similar behaviors.

[0042] Thirdly, a spectrum-temporal attention mechanism based on Discrete Cosine Transform (DCT) is introduced, enabling the model to "see" the fingerprint features of behavior in the frequency domain without requiring any additional learnable parameters. This has a decisive advantage in recognizing highly periodic behaviors, significantly improving the recognition accuracy of such behaviors.

[0043] Fourthly, the Channel Attention (CAM) mechanism can adaptively filter effective information channels and automatically suppress invalid noise generated by body tremors. Specifically, this module can automatically learn to assign high weights to head sensors during "eating" and high weights to leg sensors during "walking," suppressing interference from invalid axes. This improves the model's robustness in dynamic and complex environments.

[0044] Fifthly, the adopted TCN architecture has parallel computing capabilities, resulting in higher training efficiency; and through dilated convolution design, it can cover a longer time window with fewer parameters, effectively capturing long-term subtle behavioral changes in estrus or early stages of disease.

[0045] Below, we will refer to Figures 1 to 5 The steps of the dairy goat behavior recognition method based on discrete cosine transform frequency domain projection described in this example embodiment will be explained in more detail.

[0046] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments.

[0047] In step S1, motion data is collected by an IMU installed on the body of the dairy goat, and corresponding behavioral video data is collected by a camera device synchronized with the IMU.

[0048] Deployment of wearable devices: like Figure 2 The diagram shows a wearable device for livestock monitoring. A wearable 9-axis accelerometer IMU was selected. One set was fixed to the sheep's jaw strap to capture subtle jaw vibrations during head movements, chewing, and rumination. The other set was fixed to the hind leg ankle to capture changes in limb posture during walking, running, and lying down. The selected sheep were all 3 months old after calving, weighing 30 kg ± 3 kg, and the experimental site was located at an experimental center of Northwest A&F University. The device's acquisition frequency was standardized to 50 Hz. The device was worn on the sheep 3 days in advance, and data reception began after the sheep's stress response subsided.

[0049] Data collection Sensor configuration: Each node includes a three-axis accelerometer, a three-axis gyroscope, and a three-axis attitude angle sensor. During data acquisition, the device transmits data in real-time to a local PC via 2.4GHz Wi-Fi and saves it as a .csv file. When the sensor is fixed, the following coordinate axis is defined: the x-axis points in the direction indicated by the sheep's head, the y-axis points horizontally to the left of the sheep's head, and the z-axis points vertically downwards, consistent with the direction of gravity on the ground.

[0050] To facilitate subsequent data annotation, two Ezviz C8B surveillance cameras were deployed in the experimental area (sheep pen and outdoor area) to cover the main activity areas of the sheep. The timestamps of the cameras and IMU devices were synchronized to collect video data of the sheep's movements, which would facilitate subsequent video comparison and labeling of behavior categories.

[0051] All collected data is synchronized with a UTC or network time server to ensure strict alignment of multi-source data on the timeline.

[0052] In step S2, the motion data is preprocessed and labeled in conjunction with the behavioral video data to obtain the input sample set; wherein, the input sample set includes the training set and the test set.

[0053] Data processing: To improve the training efficiency and recognition accuracy of the behavior recognition model, the collected raw sensor data is standardized and denoised to enhance feature representation and eliminate numerical differences and noise interference between different channels.

[0054] 1. Data Sampling and Cleaning: Due to potential sampling frequency fluctuations in hardware devices, the frequency of all acquired data was standardized. A Stratified Random Down-sampling algorithm was employed to standardize data above 50Hz to 50Hz, and cubic spline interpolation was used for data with more than 5 consecutive missing sampling points. This frequency was verified to effectively control data volume and power consumption while ensuring the capture of motion details.

[0055] 2. Data Standardization: To eliminate the differences in dimensions between different sensors (such as acceleration g and angular velocity rad / s) and accelerate model convergence, each channel is standardized independently:

[0056] in and These are the mean and standard deviation of the channel on the training set, respectively. This is the standardized result. It can eliminate the interference of amplitude differences between channels and improve the model's ability to fairly model features.

[0057] 3. Data Denoising: To remove random noise generated during sensor acquisition, high-frequency interference from sheep body shaking, environmental interference, and equipment electrical noise, while retaining the main characteristic components, this embodiment employs discrete wavelet transform for filtering. Decomposition and reconstruction denoising are performed using the db6 wavelet basis function, and signal reconstruction is performed using the processed wavelet coefficients to output smoothed motion time-series data. This effectively suppresses noise components while retaining key frequency band information representing the behavior, providing high-quality input for subsequent behavior recognition models. Figure 3 The image shown is a comparison before and after noise reduction.

[0058] 4. Time Window Segmentation: To capture the complete action cycle while ensuring the stability of the data input, this embodiment uses a sliding window technique to slice the time-series data. The sliding window length L is set to 128 sampling points (corresponding to approximately 2.56 seconds), and the sliding step size is 64 sampling points (i.e., 50% overlap), forming a tensor input of shape (B, C, 128), where C is the number of channels.

[0059] Dataset Construction The acceleration data was randomly divided into a training set and a test set, ensuring a roughly balanced number of different behaviors. To verify the model's performance and generalization ability, the constructed test set was divided into a training set and a test set in an 8:2 ratio. The partitioning process used random partitioning with a fixed random seed to ensure reproducible results. The final dataset constructed in this application contains approximately 100,000 samples. In this embodiment, the training set is used to train the model, and the test set is used to verify the model's generalization ability.

[0060] In steps S3 to S5, a CNN-TCN behavior recognition model is constructed. The CNN-TCN behavior recognition model includes a feature extraction front-end module, a temporal modeling backbone module, and an attention enhancement module connected in sequence. The CNN-TCN behavior recognition model is trained and tested using the input sample set to obtain a trained CNN-TCN behavior recognition model. The movement data of the dairy goat to be recognized is input into the trained CNN-TCN behavior recognition model, and the corresponding behavior category is output.

[0061] Model building This application proposes a deep learning-based goat behavior recognition model (i.e., a framework diagram of the CNN-TCN behavior recognition model). It employs a one-dimensional convolutional neural network (1D-CNN) and a temporal convolutional network (TCN) as its backbone structure, fusing a channel-based and discrete cosine transform temporal attention module (CSTA) to enhance the model's ability to capture, refine, and augment the spatiotemporal features of multi-source sensor data and its ability to model long-range temporal dependencies. Figure 4 The diagram shown is a framework diagram of the CNN-TCN behavior recognition model. The model takes as input nine-axis time-series data (head and legs) extracted from multiple locations via a sliding window, and outputs seven categories of dairy goat behavior labels, including walking, standing, grazing, lying down, ruminating, running, and drinking.

[0062] 1. Local Feature Extraction Stem Network The input raw sensor data is represented as follows: This refers to the batch size. This represents the number of sensor channels (9 axes / sensor, 18 channels in total). The time window length is 128 sampling points. First, a standard 1D convolutional layer is used to capture local short-time patterns (e.g., signal peaks or edge abrupt changes). The operation on the j-th output channel and at time step t is defined as follows:

[0063] Where w represents the learnable convolutional kernel weights, b is the bias term, k is the convolutional kernel size, and BN represents batch normalization. The input data has 18 channels (18 axes in this application); K represents the size of the one-dimensional convolution kernel. This represents the learnable weight of the j-th convolutional kernel at position k on the m-th input channel. This represents the bias term of the j-th convolution kernel. This represents the input data of the m-th channel at time step t+k; ReLU: represents the linear rectified activation function. This stage projects the input to a higher-dimensional feature space.

[0064] 2. Temporal Modeling Network Animal behaviors (such as walking, eating, and rumination) are typically persistent and context-dependent. While traditional recurrent neural networks (RNNs) can process sequential data, their serial computation limits training efficiency and makes it difficult to capture dependencies in very long sequences. Therefore, temporal convolutional networks (TCNs) are used as the backbone for temporal modeling.

[0065] To capture the evolution of behavior over a longer time span, a Temporal Convolutional Network (TCN) is used. Its core component is the Dilated Causal Convolution. For the input sequence... and filter The dilation convolution operation F at element s is defined as:

[0066] in It is the dilation factor, and k is the kernel size. This represents dilated convolution. It involves exponentially increasing the number of layers in a stack. The receptive field can grow exponentially without loss of resolution. x represents the input one-dimensional time series data; : Represents the filter (convolution kernel) function. The output of the TCN is stabilized through residual connections:

[0067] in, This represents the feature map output by the TCN module, which contains rich temporal context information. This represents the input to the TCN module; DilatedConv indicates the dilated convolution operation layer.

[0068] 3. Channel-Spectrum-Temporal Attention Module (CSTA Module) like Figure 5 The diagram shown is a structural diagram of the CSTA module. TCN output. While containing rich temporal context, redundancy may exist in sensor channels and time segments. Since different goat behaviors exhibit significant differences in their behavior along sensor axes, indiscriminately utilizing all channels would introduce noise. The CAM module aims to adaptively assign weights to each feature channel. A DCT-based spectral-temporal attention (STM) module is introduced. Unlike traditional learnable convolutional kernels, this module utilizes fixed, non-trainable 1D Discrete Cosine Transform (DCT) basis functions to project features into the frequency domain. This not only avoids introducing additional convolutional parameters but also leverages the energy concentration properties of DCT to explicitly capture periodic frequency features of behaviors such as rumination and chewing. 3.1 Channel Attention Module (CAM) In multimodal inertial sensor data, the activation distribution of different behavioral patterns along sensor axes exhibits significant spatial heterogeneity. For example, the "head-down grazing" behavior of goats primarily causes dramatic fluctuations in vertical acceleration (e.g., the Y-axis), while the change in horizontal angular velocity is relatively weak. To address the problem of heterogeneous noise interference in multi-sensor data, this module explicitly learns to automatically assign high weights to head sensors during "grazing" behavior and to leg sensors during "walking," suppressing interference from ineffective axes. The channel attention mechanism explicitly models the dependencies between channels by aggregating global spatial statistics. It adaptively assigns high weights to sensor channels carrying key information based on the current input behavioral context, while suppressing environmental noise introduced by irrelevant channels. This process effectively improves the signal-to-noise ratio (SNR) of the feature maps, providing a cleaner feature data foundation for subsequent time-series analysis.

[0069] The CAM module aims to identify which sensor channels (axis) are most informative about the current motion. Spatial information is aggregated along the time dimension L using Global Average Pooling (GAP) and Global Max Pooling (GMP).

[0070] Wherein, F is input to the feature map of the attention module (i.e. L is the length of the time dimension; For global average pooling; This is for global max pooling.

[0071] These descriptors are processed through a shared multilayer perceptron (MLP) to generate channel attention maps.

[0072] in This represents the Sigmoid activation function. The feature map is refined through channels. The calculation is as follows:

[0073] in This represents element-wise multiplication; Feature map refined by channel attention.

[0074] 3.2 DCT-based Spectral-Temporal Attention (STM) Traditional temporal attention mechanisms (such as max-pooling-based spatial attention) primarily focus on the amplitude saliency of signals, easily overlooking periodic signals with small amplitudes but important semantics. However, animal behaviors such as rumination and steady-state walking possess unique spectral signatures in the frequency domain. Traditional spatial attention uses learnable convolutional kernels, which are prone to overfitting and computationally expensive. This application innovatively employs non-trainable DCT basis functions as filters, introducing a 1DDCT-based spectral-temporal attention module, endowing the network with "frequency-awareness" capabilities. The DCT basis functions, as a set of multi-band filters, can capture the oscillation frequency and energy distribution of features in the time dimension. Even with weak signal amplitudes, as long as a frequency component matching a specific behavior is detected, this module can accurately pinpoint the corresponding time segment and assign it high weight. This enables the model to effectively extract physically meaningful behavioral rhythmic features from cluttered sensor data, significantly enhancing the ability to recognize subtle, periodic movements.

[0075] Standard temporal attention mechanisms are typically based on convolution or max pooling, focusing only on the amplitude of the signal. However, many animal behaviors (such as rumination and running) exhibit unique periodic characteristics in the frequency domain. To explicitly capture these "behavioral rhythms," attention mechanisms based on 1D discrete cosine transform (DCT) are introduced. Frequency Feature Extraction: First, compress the channel dimensions of F\prime to obtain a global time view: :

[0076] in, The global time series obtained by averaging all channel features has a dimension of [missing information]. It represents the change in overall motion energy over time; This represents the number of feature channels.

[0077] Frequency components are extracted using fixed 1DDCT basis functions. The basis function B for the k-th frequency component is... k Defined as:

[0078] in, : The value of the DCT basis function for the k-th frequency component at time i. This is a fixed cosine waveform and does not require training; k is the frequency index, representing the different frequency components. L is the time series length.

[0079] The first K low-frequency and mid-frequency component vectors Freq are extracted through convolution. When k=0, this operation is equivalent to global average pooling; while when k>0, it can capture the oscillation frequency and periodic pattern of the signal.

[0080] in, This represents the calculated intensity of the k-th frequency component. This is actually the input signal. With basis functions The convolution (or inner product) of. A spectral eigenvector containing the first k lowest frequency components.

[0081] The feature map is mapped back to the time dimension through a fully connected layer to generate temporal attention weights Mt, and the output feature map Fout is introduced. Residual links are introduced to prevent feature degradation.

[0082]

[0083] in, It is the generated temporal attention weight graph, with dimensions... It indicates which time periods contain important behavioral rhythms. It is a learnable weight matrix of the fully connected layer, used to map frequency domain features back to time domain weights. It is the refined feature map that is finally output by the CSTA module.

[0084] Channel attention first eliminates interference from irrelevant sensors, ensuring that the spectrum-time attention module performs frequency analysis on high-quality feature maps. This cascaded synergy maximizes the efficiency of both sub-modules, resulting in a final feature representation that is both clearly sensor-oriented and rich in behavioral rhythm information.

[0085] The Channel-Spectrum-Temporal Attention (CSTA) module is configured at the output of the Temporal Convolutional Network (TCN) and includes a sequentially connected channel attention submodule and a spectrum-temporal attention submodule. The channel attention submodule is configured to perform global average pooling and global max pooling along the time dimension on the input feature map, generating channel weight vectors via a shared multilayer perceptron to weight the sensor channel features. The spectrum-temporal attention submodule is configured to perform channel aggregation on the channel-weighted feature map, extract multi-band spectral features using a preset fixed one-dimensional discrete cosine transform (DCT) convolutional kernel, and map the spectral features into temporal attention weight vectors through a fully connected layer for secondary weighting of the feature map in the time dimension. This structure can simultaneously filter key sensors in the spatial dimension and enhance behavioral segments with specific frequency features in the temporal dimension. It significantly improves the model's temporal perception granularity and stage representation ability for key behavioral segments, thereby enhancing the overall accuracy and robustness in the dairy goat behavior recognition task.

[0086] 3.3 Classification Results Feature map refined by the CSTA module It includes denoised high-level semantic features with clear spatiotemporal orientation. A global average pooling layer is used to compress these features into a fixed-length vector, completely eliminating the influence of the temporal dimension. Finally, a fully connected layer and a softmax activation function are used to calculate the conditional probability distribution of the input sample belonging to N behavioral categories:

[0087] in, It is the final output predicted probability vector, with a length of ; It is the weight matrix of the fully connected classification layer; The total number of behavior categories; It is the bias term of the fully connected classification layer.

[0088] 4. Model Training Process To verify the effectiveness and computational efficiency of the proposed CNN-TCN-CSTA model, all experiments were conducted on a high-performance computing workstation. For hardware configuration, the central processing unit (CPU) was an Intel Core i9-12900K, equipped with 128GB of DDR5 memory. Deep learning acceleration computation utilized an NVIDIA GeForce RTX 3090 GPU with 24GB of GDDR6X video memory, capable of supporting parallel training on large batch sizes and tensor operations on long-term data. The software environment was based on the Windows 11 Professional operating system. Model building and training were based on the Python 3.9 and PyTorch 1.13.1 deep learning framework, coupled with the CUDA 11.7 and CUDNN 8.5 acceleration libraries to maximize the parallel computing capabilities of the GPU.

[0089] The model training employed an end-to-end supervised learning approach. The dataset was randomly divided into training, validation, and test sets in an 8:2 ratio. To fully utilize the RTX 3090's memory advantage and ensure the stability of gradient descent, the batch size was set to 128. During training, an early stopping mechanism was used to monitor the validation set accuracy and prevent overfitting. After training, model snapshots from multiple training epochs were selected and evaluated on the test set. The model with the best accuracy and F1-score was selected as the final model and saved. It can be directly integrated into smart terminals or backend behavior recognition systems for deployment.

[0090] In one specific embodiment, the experimental process (1) Experimental data The experiment was conducted in Yangling Demonstration Zone, Shaanxi Province, in the central part of the Guanzhong Plain in Shaanxi. Data was collected from the Animal Husbandry Experiment Center of Northwest A&F University.

[0091] This experiment used an acceleration-based data acquisition system. Each sheep wore a wearable device with two integrated sensors, encapsulated in a waterproof ABS shell at the bottom, worn on the lower jaw and left hind leg. The device integrated a three-axis accelerometer, a three-axis gyroscope, and a three-axis magnetometer. It supported real-time transmission of 9-axis data to a local PC via 2.4 GHz Wi-Fi (UDP protocol). The power system used a 1000 mAh, 3.7 V lithium polymer battery, providing a 24-hour battery life. During the experiment, three dairy goats were randomly selected from the sheepfold and fitted with collar-type accelerometer sensors for continuous 24-hour data collection. The sheep were replaced after two days of collection, with a total of five groups rotated to enhance data diversity and representativeness.

[0092] In addition, to assist in behavioral labeling, researchers installed two monitoring cameras in the sheepfold, one on the beam and the other on the pillar, to capture the sheep's behavior inside and outside the sheepfold, achieving comprehensive coverage of the sheep's activity area. Camera 1 recorded the sheep's behavior inside the sheepfold, while camera 2 recorded their behavior in the field. The camera and sensor timestamps were synchronized to ensure data consistency. Behavioral labeling was performed on the collected IMU data by comparing the monitoring video with the sensor timestamps. Observations showed that common typical behaviors of dairy goats include: drinking, feeding, standing, walking, lying down, running, and rumination, totaling seven categories. This embodiment mainly focuses on classifying and identifying these seven behaviors. The labeling descriptions and sample numbers for these seven behaviors are shown in Table 1.

[0093] Table 1. Definition of Behavior

[0094] (2) Test plan 1. All experiments in this embodiment were conducted on a high-performance computing workstation. In terms of hardware configuration, the central processing unit (CPU) was an Intel Core i9-12900K, equipped with 128GB of DDR5 memory. Deep learning acceleration computing utilized an NVIDIA GeForce RTX 3090 GPU, which has 24GB of GDDR6X video memory, capable of supporting parallel training with large batch sizes and tensor operations on long-term data. The software environment was based on the Windows 11 Professional operating system. Model building and training were based on the Python 3.9 and PyTorch 1.13.1 deep learning framework, combined with the CUDA 11.7 and CUDNN 8.5 acceleration libraries to maximize the parallel computing capabilities of the GPU.

[0095] The model training employed an end-to-end supervised learning approach. The dataset was randomly divided into training, validation, and test sets in an 8:2 ratio. To fully utilize the memory advantages of the RTX 3090 and ensure the stability of gradient descent, the batch size was set to 128. An early stopping mechanism was used during training to monitor the validation set accuracy and prevent overfitting.

[0096] After training, model snapshots from multiple training epochs are selected and evaluated on the test set. The model with the best accuracy and F1-score is selected as the final model and saved. After training, the model is deployed on smart terminals or backend behavior recognition systems for real-time recognition.

[0097] 2. Comparative Experiment To verify the model performance in this embodiment, RNN, LSTM, TCN, BiLSTM, and TCN and Transformer deep learning models were compared. These are all representative networks commonly used in the field of time series modeling. All models were trained and tested under the same data preprocessing procedures and standardized dataset conditions.

[0098] Table 2 Comparison of experimental results

[0099] 3. Ablation test Table 3 Ablation Experiment Results

[0100] Experimental results show that the CNN-TCN-CSTA model proposed in this application significantly outperforms existing mainstream methods in all evaluation metrics. As shown in Table 2, the model achieves an accuracy of 98.63% and an F1 score of 0.98, which not only significantly outperforms traditional RNN models but also improves upon Transformer and standard TCN, demonstrating its superior performance in capturing complex temporal features. Furthermore, the ablation experiments in Table 3 further verify the effectiveness of the internal mechanism of the CSTA module: after introducing Channel Attention (CAM) and Spectral-Temporal Attention (STM) sequentially on top of the CNN-TCN baseline network, the model's recall gradually and steadily increased to 98.94%, and the F1 score also increased from 0.973 to 0.989. This fully demonstrates that the synergistic effect of channel selection and frequency domain rhythm perception can effectively enhance the model's ability to represent key behavioral features, thereby achieving high-precision behavior recognition.

[0101] These experimental evidences fully demonstrate that the fusion architecture constructed in this application not only has a powerful ability to extract temporal features, but also effectively solves the problem that traditional methods are unable to accurately identify subtle rhythmic movements by introducing a frequency domain sensing mechanism, providing an efficient and reliable solution for high-precision animal behavior monitoring.

[0102] In summary, this application has the following significant beneficial effects: Strong anti-interference capability: This application abandons the traditional visual recognition path and adopts contact inertial sensing technology, which completely solves the interference of environmental factors such as dim light, obstructed vision, and overlapping bodies on recognition accuracy, and realizes all-weather automated monitoring.

[0103] Multi-point fusion enhances recognition granularity: An innovative "head + leg" dual-point data fusion strategy is adopted. Compared with a single head sensor, this method can effectively distinguish between "standing" and "walking" (leg data differences), and between "lying down ruminating" and "standing ruminating" (posture angle differences), significantly reducing the misjudgment rate of similar behaviors.

[0104] Breakthrough Frequency Domain Awareness (STM Module): Existing deep learning models often focus on temporal features, easily neglecting the rhythmicity of behavior. Actions such as rumination and feeding in dairy goats exhibit high periodicity, but traditional deep learning models only consider the "peaks and troughs" (temporal amplitude), making them susceptible to interference from the randomness of individual action amplitudes. This application introduces a spectrum-temporal attention mechanism based on Discrete Cosine Transform (DCT), enabling the model to "see" the fingerprint features of behavior in the frequency domain without requiring any additional learnable parameters. This has a decisive advantage in recognizing highly periodic behaviors, significantly improving the recognition accuracy of such behaviors.

[0105] Intelligent Feature Selection (CAM Module): To address the issue of heterogeneous noise interference in multi-sensor data, the Channel Attention (CAM) mechanism adaptively selects effective information channels and automatically suppresses invalid noise generated by body tremors. Specifically, this module automatically learns to assign high weights to head sensors during "eating" behavior and high weights to leg sensors during "walking," suppressing interference from invalid axes. This improves the model's robustness in dynamic and complex environments.

[0106] Efficient long-term modeling (CNN-TCN architecture): Compared with traditional LSTM / RNN models, the TCN architecture adopted in this application has parallel computing capabilities and higher training efficiency; and through dilated convolution design, it can cover a longer time window with fewer parameters, effectively capturing long-term subtle behavioral changes in estrus or early stages of disease.

[0107] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this disclosure. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.

[0108] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the appended claims.

Claims

1. A method for recognizing the behavior of dairy goats based on discrete cosine transform frequency domain projection, characterized in that, include: Motion data is collected by an IMU installed on the body of a dairy goat, and corresponding behavioral video data is collected by a camera device synchronized with the IMU time. The motion data is preprocessed and labeled in conjunction with the behavioral video data to obtain the input sample set, which includes a training set and a test set. Construct a CNN-TCN behavior recognition model; the CNN-TCN behavior recognition model includes a feature extraction front-end module, a temporal modeling backbone module, and an attention enhancement module connected in sequence; The CNN-TCN behavior recognition model is trained and tested using the input sample set to obtain a trained CNN-TCN behavior recognition model; The movement data of the dairy goats to be identified is input into the trained CNN-TCN behavior recognition model, which outputs the corresponding behavior category.

2. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 1, characterized in that, Preprocessing motion data includes: A hierarchical random downsampling algorithm was used to standardize all motion data to a frequency of 50Hz. Z-score standardization is performed independently for each sensor channel; Discrete wavelet transform is used for filtering and noise reduction; The sliding window technique sets the window length to 128 sampling points and the sliding step size to 64 sampling points, forming input samples with a 50% overlap rate.

3. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 2, characterized in that, The feature extraction front-end module consists of alternating layers of 1D-CNN networks and pooling layers; the processing procedure of the feature extraction front-end module is as follows: The 1D-CNN network extracts shallow geometric features and local waveform patterns from the input sample set, and flattens the feature vectors through the Flatten layer to obtain a high-dimensional feature map; Pooling layers reduce the dimensionality of high-dimensional feature maps to obtain initial feature maps.

4. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 3, characterized in that, In a 1D-CNN network, the operation at the j-th output channel and time step t is as follows: in, Let be the local feature output value of the j-th output channel at time step t. It is a linear rectified activation function. For batch normalization, The number of channels for the input data. The size of the one-dimensional convolution kernel. Let k be the learnable weight of the j-th convolutional kernel at position k on the m-th input channel. To represent the input data of the m-th channel at time step t+k, This is the bias term for the j-th convolutional kernel; The high-dimensional feature map is as follows: in, For batch size, The number of feature channels, The length is the time dimension.

5. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 4, characterized in that, The temporal modeling backbone module consists of multiple layers of one-dimensional dilated convolutions; the processing procedure of the temporal modeling backbone module is as follows: The time-series modeling backbone module extracts multi-band energy distribution features from the initial feature map to obtain the input feature map.

6. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 5, characterized in that, The dilation convolution operation is as follows: in, Given one-dimensional time series data as input, For dilated convolution, For filter functions, It is the expansion factor. For the input time series at the offset The value at; The output of the time series modeling backbone module is stabilized through residual connections: in, This represents the final output feature map. Represents the initial feature map; This indicates the layer performing the dilated convolution operation.

7. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 6, characterized in that, The attention enhancement module includes a sequentially connected channel attention submodule and a spectrum-time series attention submodule; the processing procedure of the attention enhancement module is as follows: The channel attention submodule performs global average pooling and global max pooling along the time dimension on the input feature map, learns the weights of each sensor channel through a shared multilayer perceptron to generate a channel attention map, and generates a refined feature map based on the channel attention map. The spectrum-temporal attention submodule averages the refined feature map to obtain a global temporal view; it uses a pre-defined one-dimensional DCT basis function as an untrainable convolution kernel to capture low-frequency and mid-frequency components in the signal to extract multi-band spectral features; it maps the multi-band spectral features to temporal attention weights through a fully connected layer to perform secondary weighting on the temporal dimension of the feature map; and it introduces residual connections to output the final feature map.

8. The method for recognizing dairy goat behavior based on discrete cosine transform frequency domain projection according to claim 7, characterized in that, In the channel attention submodule, spatial information is aggregated along the time dimension L using global average pooling and global max pooling: in, For the initial feature map , The length is the time dimension; For global average pooling, This is for global max pooling; The channel attention map is as follows: in, This represents the Sigmoid activation function; The refined feature map is as follows: in, This represents element-wise multiplication; In the spectrum-temporal attention submodule, the global temporal view is as follows: in, Let c be the feature sequence vector of the c-th channel in the feature map at all time steps; The one-dimensional DCT basis functions are: in, Let be the value of the DCT basis function of the k-th frequency component at time i; The first K low-frequency and mid-frequency component vectors are extracted through convolution operation: in, The intermediate frequency component vector; The time attention weights are: in, This is the first learnable weight matrix. This is the second learnable weight matrix; The final feature map is as follows: in, This is the feature map after channel attention refinement.