CARVIEW |
Select Language
HTTP/2 200
date: Sat, 19 Jul 2025 13:55:54 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"77dac1ea5dad978397e42be9657549a9"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=MXcxK0%2FosO5VlxlJUmKCRcSos8HWw6THsFmN863ulDsOVU9PcBRagZdY%2F3yuK%2BJVVBDvOuu2ytjvT0TWJ753MLJwDOLOdr7odbltkfirROI5%2FqRdWLThTwvt4PWzNzenNuo1PlM8WYoKRpsRkw%2F1%2BYfLF4VWQTNgnNChsl6kfE7Dz71KuqW6AOBSoumDt8UOQRRmT5G51KlFzDBb7qCl6AFRvQt9lCXqMYxvtKICBlaRS6hijTAxYFjHtV2VWPRnc2WRkko3mhpLd6LzIR2dqQ%3D%3D--NKvyIHCo25HHqF%2Fc--NkrjTkLn3BuP2rcchbHn8w%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1027513979.1752933354; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 13:55:54 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 13:55:54 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: 9284:9AEBD:5516EB:6AB36F:687BA3EA
GitHub - eladhoffer/ImageNet-Training: ImageNet training using torch
Deep Learning on ImageNet using Torch
=====================================
This is a complete training example for Deep Convolutional Networks on the ILSVRC classification task.
Data is preprocessed and cached as a LMDB data-base for fast reading. A separate thread buffers images from the LMDB record in the background.
Multiple GPUs are also supported by using nn.DataParallelTable (https://github.com/torch/cunn/blob/master/docs/cunnmodules.md).
This code allows training at 4ms/sample with the AlexNet model and 2ms for testing on a single GPU (using Titan Z with 1 active gpu)
## Dependencies
* Torch (https://torch.ch)
* "eladtools" (https://github.com/eladhoffer/eladtools) for optimizer.
* "lmdb.torch" (https://github.com/eladhoffer/lmdb.torch) for LMDB usage.
* "DataProvider.torch" (https://github.com/eladhoffer/DataProvider.torch) for DataProvider class.
* "cudnn.torch" (https://github.com/soumith/cudnn.torch) for faster training. Can be avoided by changing "cudnn" to "nn" in models.
To install all dependencies (assuming torch is installed) use:
```bash
luarocks install https://raw.githubusercontent.com/eladhoffer/eladtools/master/eladtools-scm-1.rockspec
luarocks install https://raw.githubusercontent.com/eladhoffer/lmdb.torch/master/lmdb.torch-scm-1.rockspec
luarocks install https://raw.githubusercontent.com/eladhoffer/DataProvider.torch/master/dataprovider-scm-1.rockspec
```
## Data
* To get the ILSVRC data, you should register on their site for access: https://www.image-net.org/
* Extract all archives and configure the data location and save dir in **Config.lua**. You can also change the saved image size by editing the default value `ImageMinSide=256`.
* LMDB records for fast read access are created by running **CreateLMDBs.lua**.
It defaults to saving the compressed jpgs (about ~24GB for training data, ~1GB for validation data when smallest image dimension is 256).
* To validate the LMDB configuration and test its loading speed, you can run **TestLMDBs.lua**.
* All data related functions used for training are available at **Data.lua**.
## Model configuration
Network model is defined by writing a .lua file in `Models` folder, and selecting it using the `network` flag.
The model file must return a trainable network. It can also specify additional training options such optimization regime, input size modifications.
e.g for a model file:
```lua
local model = nn.Sequential():add(...)
return --optional: you can also simply return model
{
model = model,
regime = {
epoch = {1, 19, 30, 44, 53 },
learningRate = {1e-2, 5e-3, 1e-3, 5e-4, 1e-4},
weightDecay = {5e-4, 5e-4, 0, 0, 0 }
}
}
```
Currently available in `Models` folder are: `AlexNet`, `MattNet`, `OverFeat`, `GoogLeNet`, `CaffeRef`, `NiN`. Some are available with a batch normalized version (denoted with `_BN`)
## Training
You can start training using **Main.lua** by typing:
```lua
th Main.lua -network AlexNet -LR 0.01
```
or if you have 2 gpus availiable,
```lua
th Main.lua -network AlexNet -LR 0.01 -nGPU 2 -batchSize 256
```
A more elaborate example continuing a pretrained network and saving intermediate results
```lua
th Main.lua -network GoogLeNet_BN -batchSize 64 -nGPU 2 -save GoogLeNet_BN -bufferSize 9600 -LR 0.01 -checkpoint 320000 -weightDecay 1e-4 -load ./pretrainedNet.t7
```
Buffer size should be adjusted to suit the used hardware and configuration. Default value is 5120 (40 batches of 128) which works well when using a non SSD drive and 16GB ram. Bigger buffer size allows better sample shuffling.
## Output
Training output will be saved to folder defined with `save` flag.
The complete netowork will be saved on each epoch as **Net_<#epoch>.t7** along with
* A complete log **Log.txt**
* Error rate summary **ErrorRate.log** and accompanying **ErrorRate.log.eps** graph
## Additional flags
|Flag | Default Value |Description
|:----------------|:--------------------:|:----------------------------------------------
|modelsFolder |./Models/ | Models Folder
|network |AlexNet | Model file - must return valid network.
|LR |0.01 | learning rate
|LRDecay |0 | learning rate decay (in # samples)
|weightDecay |5e-4 | L2 penalty on the weights
|momentum |0.9 | momentum
|batchSize |128, | batch size
|optimization |'sgd' | optimization method
|seed |123 | torch manual random number generator seed
|epoch |-1 | number of epochs to train, -1 for unbounded
|testonly |false | Just test loaded net on validation set
|threads |8 | number of threads
|type |'cuda' | float or cuda
|bufferSize |5120 | buffer size
|devid |1 | device ID (if using CUDA)
|nGPU |1 | num of gpu devices used
|constBatchSize |false | do not allow varying batch sizes - e.g for ccn2 kernel
|load |'' | load existing net weights
|save |time-identifier | save directory
|optState |false | Save optimization state every epoch
|checkpoint |0 | Save a weight check point every n samples. 0 for off
|augment |1 | data augmentation level - {1 - simple mirror and crops, 2 +scales, 3 +rotations}
|estMeanStd |preDef | estimate mean and std. Options: {preDef, simple, channel, image}
|shuffle |true | shuffle training samples
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 42
ImageNet training using torch
License
eladhoffer/ImageNet-Training
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
ImageNet training using torch
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
You can’t perform that action at this time.