{"id":27860625,"url":"https://github.com/vietnh1009/very-deep-cnn-tensorflow","last_synced_at":"2025-10-20T00:38:52.158Z","repository":{"id":38391696,"uuid":"168575661","full_name":"vietnh1009/Very-deep-cnn-tensorflow","owner":"vietnh1009","description":"Very deep CNN for text classification ","archived":false,"fork":false,"pushed_at":"2021-12-26T19:44:34.000Z","size":18136,"stargazers_count":21,"open_issues_count":1,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-01-03T01:09:21.562Z","etag":null,"topics":["deep-learning","deep-neural-networks","deeplearning","document-classification","natural-language-processing","nlp","nlp-machine-learning","tensorflow","text-classification","vdcnn","very-deep-cnn"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vietnh1009.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-31T18:36:38.000Z","updated_at":"2024-06-17T15:28:24.000Z","dependencies_parsed_at":"2022-08-18T23:00:36.683Z","dependency_job_id":null,"html_url":"https://github.com/vietnh1009/Very-deep-cnn-tensorflow","commit_stats":null,"previous_names":["vietnh1009/very-deep-cnn-tensorflow","uvipen/very-deep-cnn-tensorflow"],"tags_count":null,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FVery-deep-cnn-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FVery-deep-cnn-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FVery-deep-cnn-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vietnh1009%2FVery-deep-cnn-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vietnh1009","download_url":"https://codeload.github.com/vietnh1009/Very-deep-cnn-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252376655,"owners_count":21738161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["deep-learning","deep-neural-networks","deeplearning","document-classification","natural-language-processing","nlp","nlp-machine-learning","tensorflow","text-classification","vdcnn","very-deep-cnn"],"created_at":"2025-05-04T17:43:29.004Z","updated_at":"2025-10-20T00:38:52.042Z","avatar_url":"https://github.com/vietnh1009.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [TENSORFLOW] Very deep convolutional networks for Text Classification\n\n## Introduction\n\nHere is my tensorflow implementation of the model described in the paper **Very deep convolutional networks for Text Classification** [paper](https://arxiv.org/abs/1606.01781). \n\n## Datasets:\n\nStatistics of datasets I used for experiments. These datasets could be download from [link](https://drive.google.com/drive/u/0/folders/0Bz8a_Dbh9Qhbfll6bVpmNUtUcFdjYmF2SEpmZUZUcVNiMUw1TWN6RDV3a0JHT3kxLVhVR2M)\n\n| Dataset                | Classes | Train samples | Test samples |\n|------------------------|:---------:|:---------------:|:--------------:|\n| AG’s News              |    4    |    120 000    |     7 600    |\n| Sogou News             |    5    |    450 000    |    60 000    |\n| DBPedia                |    14   |    560 000    |    70 000    |\n| Yelp Review Polarity   |    2    |    560 000    |    38 000    |\n| Yelp Review Full       |    5    |    650 000    |    50 000    |\n| Yahoo! Answers         |    10   |   1 400 000   |    60 000    |\n| Amazon Review Full     |    5    |   3 000 000   |    650 000   |\n| Amazon Review Polarity |    2    |   3 600 000   |    400 000   |\n\n## Setting:\n\nI almost keep default setting as described in the paper.\n\nAdditionally, in the original model, one epoch is seen as a loop over batch_size x num_batch records (128x5000 or 128x10000 or 128x30000), so it means that there are records used more than once for 1 epoch. In my model, 1 epoch is a complete loop over the whole dataset, where each record is used exactly once.\n\n## Training\nAfter putting 2 files **train.csv** and **test.csv** from any dataset mentioned above into **data** folder, there are several options for training:\n\nIf you want to train a model with common dataset and default parameters, you could run:\n- **python train.py**\n\nIf you want to train a model with your preference parameters, like depth and learning rate, you could run:\n- **python train.py --depth 29 --lr learning_rate**: For example, python train.py --depth 29 --lr 0.001\n\nIf you want to train a model with your own dataset, you need to specify the paths to input (train and test files) and output folder:\n- **python train.py --train_set path/to/training/file --test_set path/to/test/file --saved_path path/to/output/folder**\n\nYou could find all trained models I have trained in [link](https://drive.google.com/open?id=1DF9WXR5Et0aV3p725vEyxTTNUAqSdn0p)\n\n## Experiments:\n\nI run experiments in 2 machines, one with NVIDIA TITAN X 12gb GPU and the other with NVIDIA quadro 6000 24gb GPU.\n\nResults for test set are presented as follows:  A(B):\n- **A** is accuracy reproduced here.\n- **B** is accuracy reported in the paper.\n\nIt should be noted that in experiments with depth is 49 layers, there is no accuracy reported in the paper. Therefore here I only show the results obtained from my experiments.\n\n|     Depth     |       9      |       17     |       29     |       49     |\n|:---------------:|:--------------:|:--------------:|:--------------:|:--------------:|\n|    ag_news    | 87.67(90.17) | 88.09(90.61) | 88.01(91.33) |    84.71     |\n|   sogu_news   | 95.67(96.42) | 95.89(96.49) | 95.73(96.82) |    95.35     |\n|    db_pedia   | 98.33(98.44) | 98.28(98.39) | 98.07(98.59) |    97.38     |\n| yelp_polarity | 94.57(94.73) | 95.20(94.95) | 94.95(95.37) |    95.08     |\n|  yelp_review  | 62.44(61.96) | 63.44(62.59) | 62.70(63.00) |    62.83     |\n|  yahoo_answer | 69.57(71.76) | 70.03(71.75) | 70.34(72.84) |    69.16     |\n| amazon_review | 60.34(60.81) | 60.98(61.19) | 60.67(61.61) |    59.80     |\n|amazon_polarity| 94.30(94.31) | 94.60(94.57) | 94.53(95.06) |    94.10     |\n\nBelow are the training/test loss/accuracy curves for each dataset's experiments (figures for 9, 17, 29-layer model are from left to right) :\n\n- **ag_news**\n\n\u003cimg src=\"visualization/ag_news_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/ag_news_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/ag_news_depth_29.png\" width=\"280\"\u003e \n\n- **sogou_news**\n\n\u003cimg src=\"visualization/sogou_news_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/sogou_news_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/sogou_news_depth_29.png\" width=\"280\"\u003e\n\n- **db_pedia**\n\n\u003cimg src=\"visualization/dbpedia_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/dbpedia_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/dbpedia_depth_29.png\" width=\"280\"\u003e \n\n- **yelp_polarity**\n\n\u003cimg src=\"visualization/yelp_review_polarity_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/yelp_review_polarity_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/yelp_review_polarity_depth_29.png\" width=\"280\"\u003e \n\n- **yelp_review**\n\n\u003cimg src=\"visualization/yelp_review_full_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/yelp_review_full_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/yelp_review_full_depth_29.png\" width=\"280\"\u003e \n\n- **amazon_review**\n\n\u003cimg src=\"visualization/amazon_review_full_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/amazon_review_full_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/amazon_review_full_depth_29.png\" width=\"280\"\u003e \n\n- **amazon_polarity**\n\n\u003cimg src=\"visualization/amazon_review_polarity_depth_9.png\" width=\"280\"\u003e \u003cimg src=\"visualization/amazon_review_polarity_depth_17.png\" width=\"280\"\u003e \u003cimg src=\"visualization/amazon_review_polarity_depth_29.png\" width=\"280\"\u003e \n\nYou could find detail log of each experiment containing loss, accuracy and confusion matrix at the end of each epoch in **trained_models/logs.txt**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietnh1009%2Fvery-deep-cnn-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvietnh1009%2Fvery-deep-cnn-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvietnh1009%2Fvery-deep-cnn-tensorflow/lists"}