A CapsNet-based early diagnosis model for liver cancer

By integrating ResNet and CapsNet into the E-CapsNet model, the problems of limited data volume and class imbalance in the early diagnosis of liver cancer are solved, achieving more efficient and accurate liver cancer diagnosis.

CN118365956BActive Publication Date: 2026-06-30XIAMEN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAMEN UNIV
Filing Date
2024-05-16
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Existing technologies face challenges in the early diagnosis of liver cancer due to the limited number of images and class imbalance, resulting in low diagnostic accuracy and efficiency.

Method used

This paper integrates the deep residual learning framework of ResNet and the high-level feature representation capabilities of CapsNet to perform early diagnosis of liver cancer using the E-CapsNet model. The design includes the Conv1 initial convolutional layer, PrimaryCaps layer and DigitCaps layer. Combined with dynamic routing and Squash operation, the accuracy of feature extraction and classification is improved.

Benefits of technology

It improves the accuracy and efficiency of early diagnosis of liver cancer, especially under conditions of limited data and class imbalance, significantly improving the training efficiency and classification accuracy of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118365956B_ABST
    Figure CN118365956B_ABST
Patent Text Reader

Abstract

An early liver cancer diagnosis model based on CapsNet involves image processing. Features are extracted from the input enhanced liver CT image and processed through a ResNet module using convolution, regularization, activation functions, and max pooling. The output features are captured in the PrimaryCaps layer to obtain primary image features, reducing dimensionality and refining the features. An additional PrimaryCaps layer is added between the PrimaryCaps and DigitCaps layers to identify and integrate local features. After classification by the DigitCaps layer, a digital capsule layer is included for dynamic routing, and a Squash operation is performed to obtain a feature map composed of 8-dimensional vectors. E-CapsNet is designed by fusing the deep residual learning framework of ResNet and the high-level feature representation capabilities of CapsNet to improve the accuracy and efficiency of early liver cancer diagnosis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of image processing technology, and in particular to a CapsNet-based early diagnosis model for liver cancer that integrates the deep residual learning framework of ResNet and the high-level feature representation capabilities of CapsNet. Background Technology

[0002] CT scans, characterized by their speed and high image resolution, are routinely used in the diagnosis of liver diseases. Therefore, plain CT scans and dynamic contrast-enhanced CT scans are the preferred methods for diagnosing early-stage liver cancer. However, the increasing number of new liver cancer cases has led to an explosive growth in the number of diagnostic images, placing immense workload on radiologists and resulting in a high rate of misdiagnosis, especially in the early stages of liver cancer. Therefore, improving the accuracy and efficiency of liver cancer diagnosis has become a pressing issue in the medical field.

[0003] In the past, traditional convolutional neural networks may have faced challenges such as information loss when transmitting information. As the number of network layers increases, the problems of vanishing or exploding gradients may become more and more serious, making the network untrainable. ResNet has solved this problem to some extent. It introduces the concept of residual learning, which uses skip connections to pass the input across layers and add it to the convolution result. The network structure is flexible and can selectively learn the increment between input and output, which helps the propagation of information, protects the integrity of information, and significantly improves accuracy (He K, Zhang X, Ren S, Sun J. Deep residual learning for image recognition[C]. Proceedings of the 2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2016, pp. 770-778.).At present, many studies have proposed applying ResNet in the field of medical image classification (Wang M, Gong X. Metastatic cancer image binary classification based on resnet model[C]. Proceedings of the 2020 IEEE 20th International Conference on Communication Technology(ICCT), 2020, pp.1356-1359; Lu L, Daigle Jr B J. Prognostic analysis of histopathological images using pre-trained convolutional neural networks: application to hepatocellular carcinoma[J]. PeerJ, 2020, 8:e8668; Romero F P, Diler A, Bisson-Gregoire G, Turcotte S, Lapointe R, Vandenbroucke-Menu F, Tang A, Kadoury S. End-to-end discriminative deep network for liver lesion classification[C]. Proceedings of the 2019 IEEE 16th International Symposium on Biomedical Imaging(ISBI 2019), 2019, pp.1243-1246; Zhang Q. A novel resnet101 model based on dense dilated convolution for image classification[J]. SN Applied Sciences, 2022, 4:1-13.).

[0004] Recently, CapsNet has gradually gained attention due to its advantages in feature extraction and representation learning. Compared with traditional convolutional neural networks, CapsNet can better capture the hierarchical structure and spatial relationships of images when modeling and representing them, and has stronger representation and generalization capabilities (Sabour S, Frosst N, Hinton GE. Dynamicrouting between capsules[J]. Advances in Neural Information Processing Systems,2017,30.).In addition, many studies have applied CapsNet in the field of medical image classification (Yang S, Lee F, Miao R, Cai J, Chen L, Yao W, Kotani K, Chen Q. Rs-capsnet: anadvanced capsule network [J]. The Multidisciplinary Open Access Journal, 2020, 8: 85007-18; Afriyie Y, Weyori BA, Opoku A A. Exploring optimized capsule network on complex images for medical diagnosis[C].Proceedings of the 2021IEEE 8thInternational Conference on Adaptive Science and Technology(ICAST),2021,pp.1-5;Zhang Z,Ye S,Liao P,Liu Y,Su G,Sun Y.Enhanced capsule network for medicalimage classification[C].Proceedings of the 2020 42nd Annual International Conference of the IEEE Engineering in Medicine&Biology Society (EMBC), 2020, pp. 1544-1547; Zhang H, Li Z, Zhao H, Li Z, Zhang Y. Attentive octave convolutional capsule network for medical image classification[J]. Applied Sciences, 2022, 12(5): 2634.). However, most studies focus on fundamentally solving the data volume problem by collecting new data or performing augmentation operations on the data, without conducting in-depth research on CapsNet in the case of limited data volume and class imbalance. Summary of the Invention

[0005] The purpose of this invention is to address the limitations of the limited number and class imbalance of enhanced liver CT images collected from patients in current clinical practice. It aims to provide a CapsNet-based early diagnosis model for liver cancer that overcomes these issues. Specifically, it proposes E-CapsNet, which integrates the deep residual learning framework of ResNet and the high-level feature representation capabilities of CapsNet, thereby improving the accuracy and efficiency of early liver cancer diagnosis.

[0006] This invention includes the following steps:

[0007] 1) Extract features from the input enhanced CT image of the liver, and perform convolution, regularization, activation function and max pooling calculations through the ResNet module, which includes the initial Conv1 convolutional layer;

[0008] 2) The features output in step 1) are further captured in the PrimaryCaps layer to capture the spatial information of the features, outputting the primary features of the image. After the dimensionality is reduced by the max pooling layer, the features are further abstracted and refined.

[0009] 3) Identify and integrate local features by designing an additional PrimaryCaps layer between the PrimaryCaps layer and the DigitCaps layer;

[0010] 4) After classification by the DigitCaps layer, which includes a digital capsule layer for dynamic routing, and then through the Squash operation, a feature map composed of 8-dimensional vectors is obtained.

[0011] In step 1), the ResNet module, which includes an initial Conv1 convolutional layer, performs convolution, regularization, activation function, and max pooling calculations to extract features from the input liver enhanced CT image. The ResNet network's method for extracting image features begins with a standard convolutional layer. The Conv1 layer does not introduce residual blocks; its function is to perform preliminary processing on the input. This layer selects a convolutional kernel size of h×h and performs downsampling with a stride of r. This is followed by a batch normalization layer and a ReLU activation function. Immediately afterward, a max pooling layer is used to further downsample with an h×h convolutional kernel and a stride of r.

[0012] The core consists of four residual blocks (Layer 1 to Layer 4), each composed of multiple residual learning units, referred to as blocks. Each block contains three convolutional layers, followed by a batch normalization layer and a ReLU activation function after the first and second convolutional layers. Within each block, identity downsampling is used if input downsampling or channel number adjustment to match output dimension is required. At the end of each block, the input is added to the output of the convolutional layer via residual connections and then passed through the ReLU activation function. This design allows each block to learn the residual between the input and output, rather than directly learning the output, thereby improving the training efficiency and accuracy of the network.

[0013] Finally, an adaptive average pooling layer maps the features to a fixed-size output, flattens them, and maps them to class prediction through a fully connected layer; the output dimension is equal to the number of classes in the classification task; the pooling layer reduces the dimensionality of the input data to retain the key information feature vectors, and finally outputs the probability of each class.

[0014] In step 2), the features output in step 1) are further captured in the primaryCaps layer to capture the spatial information of the features, outputting the primary features of the image. After the dimensionality is reduced by the max pooling layer, the features are further abstracted and refined. The entire framework of CapsNet consists of three core parts: convolutional layers, primaryCaps layers, and digitCaps layers. The primaryCaps layer is responsible for storing low-level feature vectors, capturing the spatial information of the features, and outputting the primary features of the image. After the dimensionality is reduced by the max pooling layer, the redundancy of the features is further reduced, and the expressive power of the features is improved.

[0015] In step 3), the design of an additional PrimaryCaps layer between the PrimaryCaps layer and the DigitCaps layer identifies and integrates local features. Two PrimaryCaps operations are performed in E-CapsNet to enhance the model's ability to understand features at different levels in the image, thereby improving the network's sensitivity to image details and the accuracy of classification.

[0016] In step 4), the classification process via the DigitCaps layer includes a digital capsule layer for dynamic routing, followed by a Squash operation to obtain a feature map composed of 8-dimensional vectors. The specific method is as follows:

[0017] In the DigitCaps layer classification task, images may contain one or more labels. Therefore, the Margin loss function is used to penalize false negatives and false positives. The loss function L... k It consists of two parts, and its formula is:

[0018] L k =T k max(0,m + -||v k ||) 2 +λ(1-T k max(0,||v) k ||-m - ) 2

[0019] Where k is the number of categories in the image where labels exist; T k As an indicator function, k exists, T k =1, otherwise T k =0;m + It is a lower bound on the length of the target vector of the correct category capsule, m - It is an upper bound on the target vector length of the error category capsule, where λ is a trade-off factor; v k It is the output vector, ||v k || represents the length of the output vector, ||·|| denotes the Euclidean norm, and max(0,·) 2 Ensure that the length of the predicted vector is less than the target length; if it exceeds the target length, the loss is zero.

[0020] The PrimaryCaps layer and the DigitCaps layer achieve efficient information transfer through an iterative dynamic routing mechanism, ensuring that the network can fully utilize the features of the underlying layers; Formula:

[0021]

[0022] in, The input to the j-th capsule is used as the prediction vector, which is obtained by using the output vector u of capsule i. i With a weight matrix W ij The weight matrix W of CapsNet is achieved through multiplication. ij Through L k The information updated by backpropagation is used to transform the information of the i-th capsule to predict the state of the j-th capsule;

[0023]

[0024]

[0025] Among them, cij The degree to which capsule i contributes to the output of capsule j is calculated using the coupling coefficient and the softmax function, ensuring that all predicted vectors reaching capsule j are considered. The sum of the coupling coefficients is 1, and Σ represents the summation operation; b ij is the log-prior probability, representing the initial connection strength between capsules i and j without any other information. These values ​​are initialized to 0 at the start of the route and are dynamically updated through the iterative process. n is the connection from all capsules i to j.

[0026] Then, calculate the input vector s for entering the next capsule j. j This is achieved by using the prediction vectors of all capsules i to j from the previous level. Their corresponding coupling coefficients c ij The result is obtained by multiplying and summing; this process essentially involves a weighted sum and aggregation of all prediction vectors to form a comprehensive prediction of the high-level capsule state; formula:

[0027]

[0028] Where s j Let Σ be the magnitude of the input vector, and Σ denote the summation operation.

[0029] CapsNet's capsules contain both orientation and length information. Without altering the capsule's orientation, the probability of an entity's existence is quantified by the length of the output vector; as the vector's magnitude increases, the probability of existence also increases. To ensure the probability remains between 0 and 1, the Squash nonlinear compression function is used, with the following formula:

[0030]

[0031] Among them, v j Let s be the output vector of the capsule. j Let ||·|| represent the magnitude of the input vector, and ||·|| denote the Euclidean norm. 2 This represents the square of the Euclidean norm.

[0032] Compared with the prior art, the present invention has the following outstanding technical effects and advantages:

[0033] This invention proposes a CapsNet-based early liver cancer diagnosis model. First, features are extracted from the input enhanced liver CT image. A ResNet module, including an initial Conv1 convolutional layer, performs convolution, regularization, activation function, and max pooling calculations. Then, a primaryCaps layer further captures the spatial information of the features, outputting the image's primary features. After reducing dimensionality through a max pooling layer, the features are further abstracted and refined. The primaryCaps layer identifies and integrates local features, followed by a DigitCaps layer for classification, including a digital capsule layer for dynamic routing. Finally, a Squash operation yields an 8-dimensional feature map for early liver cancer diagnosis. Compared to existing technologies, this invention utilizes an E-CapsNet early liver cancer diagnosis model that integrates the deep residual learning framework of ResNet and the high-level feature representation capabilities of CapsNet. This model addresses the limitations of the limited number and class imbalance of enhanced liver CT images collected clinically, providing strong support for improving the accuracy and efficiency of early liver cancer diagnosis. Attached Figure Description

[0034] Figure 1 This is a schematic diagram of the E-CapsNet network structure.

[0035] Figure 2 The figures represent the performance of the three models ResNet50, ViT and E-CapsNet in the embodiment under different data volumes of enhanced CT images of the liver, where (a) is accuracy, (b) is sensitivity and (c) is specificity.

[0036] Figure 3 The above represents the performance of the three models ResNet50, ViT and E-CapsNet on enhanced CT images of the liver in the embodiment on an imbalanced dataset, where (a) is accuracy, (b) is sensitivity, (c) is specificity and (d) is F1 score. Detailed Implementation

[0037] To make the objectives, technical solutions, and advantages of this invention clearer, the following embodiments will be used in conjunction with the accompanying drawings to further illustrate the invention. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. The dataset used in the embodiments of this invention comprises 1009 patients with cirrhosis and 98 patients with liver cancer with a background of cirrhosis who were hospitalized at the Affiliated Hospital of Southwest Medical University from March 2016 to December 2020, and was approved by the hospital's ethics committee. Postoperative liver failure was assessed in the 98 liver cancer patients according to the ISGLS criteria; 23 patients developed liver failure postoperatively, and 75 did not. The number of cases is limited, and there is an imbalance in the categories.

[0038] The embodiments of the present invention include the following steps:

[0039] Step 1: First, horizontal slice images of the liver portal venous phase CT images of 1107 patients were obtained. Then, the image storage format of the raw data was converted, and each slice of the liver CT image in NIfTI format was converted to .png format. Next, a radiologist with 3 years of experience selected 1014 liver cancer images and 1009 liver cirrhosis images as valid images to make the data distribution more balanced. 80% of the images were selected as the training set to train the model, and 20% were selected as the test set to test the training effect.

[0040] Then, the ResNet module in E-CapsNet, including the initial Conv1 convolutional layer, performs convolution, regularization, activation function, and max pooling calculations to extract features from the input liver-enhanced CT image. The ResNet network's feature extraction method begins with a standard convolutional layer. Conv1 does not introduce residual blocks; its function is to perform preliminary processing of the input. This layer uses a 7×7 convolutional kernel and downsampling with a stride of 2, followed by a batch normalization layer and a ReLU activation function. Immediately after, a max pooling layer further downsamples using a 3×3 convolutional kernel and a stride of 2. The core consists of four residual blocks (Layer 1 to Layer 4), each composed of multiple residual learning units, called blocks. Each block contains three convolutional layers: a 1×1 convolutional layer for dimensionality reduction; a 3×3 convolutional layer for feature learning; and a 1×1 convolutional layer for feature expansion. Each convolutional layer is followed by a batch normalization layer, and then a ReLU activation function after the first and second convolutional layers. Within each block, identity downsampling is used if input downsampling or channel adjustment to match the output dimension is required, achieved through 1×1 convolutions and stride adjustments. At the end of each block, the input is added to the output of the convolutional layer via a residual connection, and then passed through the ReLU activation function. This design allows each block to learn the residual between the input and output, rather than directly learning the output, thus improving the network's training efficiency and accuracy.

[0041] Finally, an adaptive average pooling layer maps the features to a fixed-size output, flattens it, and then maps it to the class prediction through a fully connected layer. The output dimension equals the number of classes in the classification task. The pooling layer reduces the dimensionality of the input data, preserving the key information in the feature vector, and finally outputs the probability of each class.

[0042] The second step involves further capturing the spatial information of the features output from the first step in the primaryCaps layer, outputting the primary features of the image. After reducing the dimensionality through a max pooling layer, the features are further abstracted and refined. The entire CapsNet framework consists of three core parts: convolutional layers, the primaryCaps layer, and the digitCaps layer. The primaryCaps layer is responsible for storing low-level feature vectors, capturing the spatial information of the features, and outputting the primary features of the image. After reducing the dimensionality through the max pooling layer, feature redundancy is further reduced, and the expressive power of the features is improved.

[0043] The third step involves designing an additional PrimaryCaps layer between the PrimaryCaps and DigitCaps layers to identify and integrate local features. This involves performing two PrimaryCaps operations in E-CapsNet, enhancing the model's ability to understand features at different levels in the image, thereby improving the network's sensitivity to image details and the accuracy of classification.

[0044] The fourth step involves classification using the DigitCaps layer, which includes a digital capsule layer for dynamic routing, followed by a Squash operation to obtain a feature map composed of 8-dimensional vectors. The specific method is as follows:

[0045] In the DigitCaps layer classification task, images may contain one or more labels. Therefore, the Margin loss function is used to penalize false negatives and false positives. The loss function L... k It consists of two parts, and its formula is:

[0046] L k =T k max(0,m + -||v k ||) 2 +λ(1-T k max(0,||v) k ||-m - ) 2

[0047] Where k is the number of categories in the image where labels exist. T kAs an indicator function, k exists, T k =1, otherwise T k =0;m + It is a lower bound on the length of the target vector of the correct category capsule, m - λ is an upper bound on the length of the target vector for the error category capsule, and λ is a tradeoff factor. Parameter setting m + =0.9, m - =0.1, λ=0.5. v k It is the output vector, ||v k || represents the length of the output vector, ||·|| denotes the Euclidean norm, and max(0,·) 2 Ensure that the length of the predicted vector is less than the target length; if it exceeds the target length, the loss is zero.

[0048] The PrimaryCaps layer and the DigitCaps layer achieve efficient information transfer through an iterative dynamic routing mechanism, ensuring that the network can fully utilize the features of the underlying layers. Formula:

[0049]

[0050] in, The input to the j-th capsule is used as the prediction vector, which is obtained by using the output vector u of capsule i. i With a weight matrix W ij The weight matrix W of CapsNet is achieved through multiplication. ij Through L k The information from the i-th layer capsule is updated and transformed using backpropagation to predict the state of the j-th layer capsule.

[0051]

[0052]

[0053] Among them, c ij The degree to which capsule i contributes to the output of capsule j is calculated using the coupling coefficient and the softmax function, ensuring that all predicted vectors reaching capsule j are considered. The sum of the coupling coefficients is 1, and Σ represents the summation operation. ij The logarithmic prior probability represents the initial connection strength between capsules i and j without any other information. These values ​​are initialized to 0 at the start of the route and are dynamically updated through the iterative process. n is the number of connections from capsule i to j.

[0054] Then, calculate the input vector s for entering the next capsule j. j This is achieved by using the prediction vectors of all capsules i to j from the previous level. Their corresponding coupling coefficients cij The result is obtained by multiplying and summing. This process essentially involves a weighted sum of all prediction vectors to form a comprehensive prediction of the high-level capsule state. Formula:

[0055]

[0056] Where s j Let Σ be the magnitude of the input vector, and Σ denotes the summation operation.

[0057] CapsNet's capsules contain both orientation and length information. Without altering the capsule's orientation, the length of the output vector quantifies the probability of an entity's existence; as the vector's magnitude increases, the probability of existence also increases. The number of output categories determines the number of capsules. The output vector is multiplied by a weight matrix to obtain the "predicted vector," which is then iteratively optimized using backpropagation. During this process, a top-down feedback mechanism uses the weight matrix and coupling coefficients to classify lower-layer information, ultimately outputting a recognition result vector v. j .

[0058] To ensure the probability is between 0 and 1, the Squash nonlinear compression function is used, with the following formula:

[0059]

[0060] Among them, v j Let s be the output vector of the capsule. j Let ||·|| represent the magnitude of the input vector, and ||·|| denote the Euclidean norm. 2 This represents the square of the Euclidean norm.

[0061] Finally, accuracy (ACC), sensitivity (SEN), specificity (SPE), and F1 score were used as evaluation metrics in the implementation example.

[0062]

[0063]

[0064]

[0065]

[0066] Among them, TP (True positive): the number of instances correctly predicted as positive; TN (Truenegative): the number of instances correctly predicted as negative; FP (False positive): the number of instances incorrectly predicted as positive; and FN (False negative): the number of instances incorrectly predicted as negative. The F1-score is a comprehensive classification task evaluation metric that assesses the model's performance on imbalanced datasets.

[0067] In this embodiment, portal venous phase CT images of 1107 patients in the dataset were processed using E-CapsNet (E-CapsNet network structure is shown below). Figure 1 As shown in Table 1, the evaluation metrics are accuracy (ACC), sensitivity (SEN), specificity (SPE), and F1 score. In examples with different dataset sizes, when the training dataset size is 25%, 50%, and 100%, the results and research metrics are shown in Table 1. Figure 2 Table 1 shows the experimental results of liver cirrhosis and liver cancer classification using enhanced CT images of the liver with three models (ResNet50, ViT, and E-CapsNet) under different data volumes in the embodiments.

[0068] Table 1. Experimental results of liver cirrhosis and liver cancer classification under different data volumes.

[0069]

[0070] In the implementation of the imbalanced dataset, four different imbalance ratios were used. The ratio of liver cancer to liver cirrhosis in the training set was 1:1, with a data volume of 800 images, serving as the baseline. By reducing the data volume of liver cancer images, three imbalanced datasets were constructed with imbalance ratios of 1:2 (400 images: 800 images), 1:4 (200 images: 800 images), and 1:5 (160 images: 800 images). The imbalance rate represents the ratio between positive and negative samples; a higher ratio indicates a more imbalanced data set. The results and research indicators are shown in Table 2. Figure 3 .

[0071] Table 2. Experimental results of liver cirrhosis and liver cancer classification on imbalanced datasets.

[0072]

[0073] Table 2 shows the experimental results of classifying liver cirrhosis and hepatocellular carcinoma using three models—ResNet50, ViT, and E-CapsNet—on an imbalanced dataset with enhanced CT images of the liver. Compared with existing technologies, this invention establishes an early diagnosis model for hepatocellular carcinoma using E-CapsNet, which integrates the deep residual learning framework of ResNet and the high-level feature representation capabilities of CapsNet. This model addresses the limitations of the number and imbalance of enhanced CT images of the liver collected from patients in clinical settings, providing strong support for improving the accuracy and efficiency of early diagnosis of hepatocellular carcinoma.

[0074] The above embodiments are merely preferred embodiments of the present invention and should not be considered as limiting the scope of the present invention. All equivalent variations and improvements made within the scope of the present invention should still fall within the patent coverage of the present invention.

Claims

1. A CapsNet-based method for early diagnosis of liver cancer, characterized by the following steps: 1) The features of the input liver enhanced CT image are extracted by the ResNet module, which includes a Conv1 initial convolutional layer and performs convolution, regularization, activation function and max pooling calculations; 2) The features output in step 1) capture the spatial information of the features in the first PrimaryCaps layer, outputting the primary features of the image. After reducing the dimensionality through the max pooling layer, the features are abstracted and refined. 3) After the max pooling layer, local features are identified and integrated again through the second PrimaryCaps layer, and then fed into the DigitCaps layer; 4) Classification is performed through the DigitCaps layer, which includes a digital capsule layer for dynamic routing. Then, a Squash operation is performed to obtain a feature map composed of 8-dimensional vectors. Specific methods include: In the DigitCaps layer classification task, images may contain one or more labels. A margin loss function is used to penalize false negatives and false positives. It consists of two parts, and its formula is: in, This represents the number of categories in which labels are present in the image. For indicator functions, exist, ,otherwise ; It is a lower bound on the length of the target vector of the correct category capsule. It is an upper bound on the length of the target vector of the error category capsule. It is a trade-off factor; It is the output vector. It is the length of the output vector. Denotes the Euclidean norm. Ensure that the length of the predicted vector is less than the target length; if it exceeds the target length, the loss is zero. The PrimaryCaps layer and the DigitCaps layer achieve efficient information transfer through an iterative dynamic routing mechanism, ensuring that the network can fully utilize the features of the underlying layers; Formula: in, It is the first The input of each capsule is used as the prediction vector, and this prediction is made by... The output vector With a weight matrix The weight matrix of CapsNet is achieved through multiplication. Through The update is completed with backpropagation and used for transformation. Information from layered capsules for prediction The state of the capsule layer; in, It is a capsule capsules The degree of output contribution is calculated using the coupling coefficient via the softmax function, ensuring that all values ​​reaching the capsule are considered valid. Prediction vector The sum of their coupling coefficients is 1. This represents the summation operation; It is the logarithmic prior probability, representing the probability of the capsule in the absence of any other information. and The initial connection strength between the links, these values ​​are initialized to 0 at the start of routing and are dynamically updated through an iterative process. It is to traverse all capsules arrive The connection; Calculate entry into the next capsule input vector By using all the capsules from the previous level right Prediction vector Their corresponding coupling coefficients The predictions are obtained by multiplying and summing; this process aggregates the weighted sums of all prediction vectors to form a comprehensive prediction of the state of the high-level capsule, as shown in the following formula: in, This represents the summation operation; CapsNet's capsules contain both orientation and length information. Without altering the capsule's orientation, the probability of an entity's existence is quantified by the length of the output vector; as the vector's magnitude increases, the probability of existence also increases. To ensure the probability remains between 0 and 1, the Squash nonlinear compression function is used, with the following formula: in, Let be the output vector of the capsule. The magnitude of the input vector. Denotes the Euclidean norm. 2 This represents the square of the Euclidean norm.

2. The method for early diagnosis of liver cancer based on CapsNet as described in claim 1, characterized in that... In step 1), the ResNet module's method for extracting image features begins with a standard convolutional layer. The initial Conv1 convolutional layer does not introduce residual blocks. This initial Conv1 convolutional layer is used for preliminary processing of the input. This layer selects a convolutional kernel size of h×h and performs downsampling with a stride of r. This is followed by a batch normalization layer and a ReLU activation function. Immediately afterward, a max pooling layer is used to further downsample the input with an h×h convolutional kernel and a stride of r. The core consists of four residual blocks, Layer 1 to Layer 4. Each block is composed of multiple residual learning units, which are called blocks. Each block contains three convolutional layers, followed by a batch normalization layer and a ReLU activation function after the first and second convolutional layers. Within each block, identity downsampling is used if it is necessary to downsample the input or adjust the number of channels to match the output dimension. At the end of each block, the input is added to the output of the convolutional layer through a residual connection and then passed through the ReLU activation function. An adaptive average pooling layer maps features to a fixed-size output, flattens them, and maps them to class predictions through a fully connected layer; the output dimension equals the number of classes in the classification task; the pooling layer reduces the dimensionality of the input data to retain the key information of the feature vector, and finally outputs the probability of each class.