or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

cnn-models.mdcore-interface.mdimagenet-integration.mdindex.mdmodel-selection.mdrnn-models.md

cnn-models.mddocs/

0

# CNN Models

1

2

Collection of convolutional neural network implementations including AlexNet, VGG16/19, ResNet50, GoogLeNet, LeNet, and other popular architectures for image classification and computer vision tasks.

3

4

## Capabilities

5

6

### AlexNet

7

8

Implementation of AlexNet CNN architecture based on "ImageNet Classification with Deep Convolutional Neural Networks". Suitable for image classification tasks with 224x224x3 input images.

9

10

```java { .api }

11

/**

12

* AlexNet CNN architecture implementation

13

*/

14

class AlexNet extends ZooModel {

15

/**

16

* Creates AlexNet with basic configuration

17

* @param numLabels Number of output classes

18

* @param seed Random seed for reproducibility

19

* @param iterations Number of training iterations

20

*/

21

AlexNet(int numLabels, long seed, int iterations);

22

23

/**

24

* Creates AlexNet with workspace mode configuration

25

* @param numLabels Number of output classes

26

* @param seed Random seed for reproducibility

27

* @param iterations Number of training iterations

28

* @param workspaceMode Memory workspace configuration

29

*/

30

AlexNet(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

31

32

/**

33

* Returns the network configuration

34

* @return MultiLayerConfiguration for the AlexNet architecture

35

*/

36

MultiLayerConfiguration conf();

37

}

38

```

39

40

**Usage Example:**

41

42

```java

43

// Create AlexNet for 1000-class ImageNet classification

44

AlexNet alexNet = new AlexNet(1000, 42, 1);

45

MultiLayerNetwork model = (MultiLayerNetwork) alexNet.init();

46

47

// Custom configuration with workspace mode

48

AlexNet customAlexNet = new AlexNet(10, 123, 1, WorkspaceMode.SINGLE);

49

ModelMetaData metadata = customAlexNet.metaData();

50

// Input shape: [3, 224, 224] (RGB, 224x224 images)

51

```

52

53

### VGG16

54

55

Implementation of VGG16 CNN architecture with support for pre-trained weights from ImageNet, CIFAR-10, and VGGFace datasets.

56

57

```java { .api }

58

/**

59

* VGG-16 CNN architecture implementation with pre-trained weights support

60

*/

61

class VGG16 extends ZooModel {

62

/**

63

* Creates VGG16 with basic configuration

64

* @param numLabels Number of output classes

65

* @param seed Random seed for reproducibility

66

* @param iterations Number of training iterations

67

*/

68

VGG16(int numLabels, long seed, int iterations);

69

70

/**

71

* Creates VGG16 with workspace mode configuration

72

* @param numLabels Number of output classes

73

* @param seed Random seed for reproducibility

74

* @param iterations Number of training iterations

75

* @param workspaceMode Memory workspace configuration

76

*/

77

VGG16(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

78

79

/**

80

* Returns the network configuration

81

* @return MultiLayerConfiguration for the VGG16 architecture

82

*/

83

MultiLayerConfiguration conf();

84

}

85

```

86

87

**Pre-trained Weights Support:**

88

- `PretrainedType.IMAGENET` - ImageNet classification weights

89

- `PretrainedType.CIFAR10` - CIFAR-10 classification weights

90

- `PretrainedType.VGGFACE` - VGGFace recognition weights

91

92

**Usage Example:**

93

94

```java

95

// Create VGG16 and load ImageNet pre-trained weights

96

VGG16 vgg16 = new VGG16(1000, 42, 1);

97

Model pretrainedModel = vgg16.initPretrained(PretrainedType.IMAGENET);

98

99

// Check available pre-trained weights

100

boolean hasImageNet = vgg16.pretrainedAvailable(PretrainedType.IMAGENET); // true

101

boolean hasCIFAR10 = vgg16.pretrainedAvailable(PretrainedType.CIFAR10); // true

102

boolean hasVGGFace = vgg16.pretrainedAvailable(PretrainedType.VGGFACE); // true

103

104

// Create for custom number of classes

105

VGG16 customVGG16 = new VGG16(10, 42, 1);

106

MultiLayerNetwork customModel = (MultiLayerNetwork) customVGG16.init();

107

```

108

109

### VGG19

110

111

Implementation of VGG19 CNN architecture, deeper variant of VGG16 with 19 layers.

112

113

```java { .api }

114

/**

115

* VGG-19 CNN architecture implementation

116

*/

117

class VGG19 extends ZooModel {

118

/**

119

* Creates VGG19 with basic configuration

120

* @param numLabels Number of output classes

121

* @param seed Random seed for reproducibility

122

* @param iterations Number of training iterations

123

*/

124

VGG19(int numLabels, long seed, int iterations);

125

126

/**

127

* Creates VGG19 with workspace mode configuration

128

* @param numLabels Number of output classes

129

* @param seed Random seed for reproducibility

130

* @param iterations Number of training iterations

131

* @param workspaceMode Memory workspace configuration

132

*/

133

VGG19(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

134

135

/**

136

* Returns the network configuration

137

* @return MultiLayerConfiguration for the VGG19 architecture

138

*/

139

MultiLayerConfiguration conf();

140

}

141

```

142

143

### ResNet50

144

145

Implementation of ResNet50 CNN architecture with residual connections for training very deep networks.

146

147

```java { .api }

148

/**

149

* ResNet50 CNN architecture implementation with residual connections

150

*/

151

class ResNet50 extends ZooModel {

152

/**

153

* Creates ResNet50 with basic configuration

154

* @param numLabels Number of output classes

155

* @param seed Random seed for reproducibility

156

* @param iterations Number of training iterations

157

*/

158

ResNet50(int numLabels, long seed, int iterations);

159

160

/**

161

* Creates ResNet50 with workspace mode configuration

162

* @param numLabels Number of output classes

163

* @param seed Random seed for reproducibility

164

* @param iterations Number of training iterations

165

* @param workspaceMode Memory workspace configuration

166

*/

167

ResNet50(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

168

}

169

```

170

171

### GoogLeNet

172

173

Implementation of GoogLeNet/Inception CNN architecture with inception modules for efficient computation.

174

175

```java { .api }

176

/**

177

* GoogLeNet/Inception CNN architecture implementation

178

*/

179

class GoogLeNet extends ZooModel {

180

/**

181

* Creates GoogLeNet with basic configuration

182

* @param numLabels Number of output classes

183

* @param seed Random seed for reproducibility

184

* @param iterations Number of training iterations

185

*/

186

GoogLeNet(int numLabels, long seed, int iterations);

187

188

/**

189

* Creates GoogLeNet with workspace mode configuration

190

* @param numLabels Number of output classes

191

* @param seed Random seed for reproducibility

192

* @param iterations Number of training iterations

193

* @param workspaceMode Memory workspace configuration

194

*/

195

GoogLeNet(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

196

197

/**

198

* Returns the network configuration

199

* @return ComputationGraphConfiguration for the GoogLeNet architecture

200

*/

201

ComputationGraphConfiguration conf();

202

}

203

```

204

205

### LeNet

206

207

Implementation of LeNet CNN architecture, one of the earliest successful CNNs for digit recognition.

208

209

```java { .api }

210

/**

211

* LeNet CNN architecture implementation for digit recognition

212

*/

213

class LeNet extends ZooModel {

214

/**

215

* Creates LeNet with basic configuration

216

* @param numLabels Number of output classes

217

* @param seed Random seed for reproducibility

218

* @param iterations Number of training iterations

219

*/

220

LeNet(int numLabels, long seed, int iterations);

221

222

/**

223

* Creates LeNet with workspace mode configuration

224

* @param numLabels Number of output classes

225

* @param seed Random seed for reproducibility

226

* @param iterations Number of training iterations

227

* @param workspaceMode Memory workspace configuration

228

*/

229

LeNet(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

230

231

/**

232

* Returns the network configuration

233

* @return MultiLayerConfiguration for the LeNet architecture

234

*/

235

MultiLayerConfiguration conf();

236

}

237

```

238

239

### SimpleCNN

240

241

Implementation of a simple CNN architecture for basic image classification tasks.

242

243

```java { .api }

244

/**

245

* Simple CNN architecture implementation

246

*/

247

class SimpleCNN extends ZooModel {

248

/**

249

* Creates SimpleCNN with basic configuration

250

* @param numLabels Number of output classes

251

* @param seed Random seed for reproducibility

252

* @param iterations Number of training iterations

253

*/

254

SimpleCNN(int numLabels, long seed, int iterations);

255

256

/**

257

* Creates SimpleCNN with workspace mode configuration

258

* @param numLabels Number of output classes

259

* @param seed Random seed for reproducibility

260

* @param iterations Number of training iterations

261

* @param workspaceMode Memory workspace configuration

262

*/

263

SimpleCNN(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

264

265

/**

266

* Returns the network configuration

267

* @return MultiLayerConfiguration for the SimpleCNN architecture

268

*/

269

MultiLayerConfiguration conf();

270

}

271

```

272

273

### InceptionResNetV1

274

275

Implementation of InceptionResNetV1 combining Inception modules with residual connections.

276

277

```java { .api }

278

/**

279

* InceptionResNetV1 architecture combining Inception modules with residual connections

280

*/

281

class InceptionResNetV1 extends ZooModel {

282

/**

283

* Creates InceptionResNetV1 with basic configuration

284

* @param numLabels Number of output classes

285

* @param seed Random seed for reproducibility

286

* @param iterations Number of training iterations

287

*/

288

InceptionResNetV1(int numLabels, long seed, int iterations);

289

290

/**

291

* Creates InceptionResNetV1 with workspace mode configuration

292

* @param numLabels Number of output classes

293

* @param seed Random seed for reproducibility

294

* @param iterations Number of training iterations

295

* @param workspaceMode Memory workspace configuration

296

*/

297

InceptionResNetV1(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

298

}

299

```

300

301

### FaceNetNN4Small2

302

303

Implementation of FaceNet NN4 Small2 architecture specifically designed for face recognition tasks.

304

305

```java { .api }

306

/**

307

* FaceNet NN4 Small2 architecture for face recognition

308

*/

309

class FaceNetNN4Small2 extends ZooModel {

310

/**

311

* Creates FaceNetNN4Small2 with basic configuration

312

* @param numLabels Number of output classes

313

* @param seed Random seed for reproducibility

314

* @param iterations Number of training iterations

315

*/

316

FaceNetNN4Small2(int numLabels, long seed, int iterations);

317

318

/**

319

* Creates FaceNetNN4Small2 with workspace mode configuration

320

* @param numLabels Number of output classes

321

* @param seed Random seed for reproducibility

322

* @param iterations Number of training iterations

323

* @param workspaceMode Memory workspace configuration

324

*/

325

FaceNetNN4Small2(int numLabels, long seed, int iterations, WorkspaceMode workspaceMode);

326

327

/**

328

* Returns the network configuration

329

* @return ComputationGraphConfiguration for the FaceNetNN4Small2 architecture

330

*/

331

ComputationGraphConfiguration conf();

332

}

333

```

334

335

## Common Usage Patterns

336

337

**Basic Model Creation:**

338

339

```java

340

// Create any CNN model with standard configuration

341

AlexNet alexNet = new AlexNet(1000, 42, 1);

342

VGG16 vgg16 = new VGG16(1000, 42, 1);

343

ResNet50 resNet50 = new ResNet50(1000, 42, 1);

344

345

// Initialize models

346

Model alexNetModel = alexNet.init();

347

Model vgg16Model = vgg16.init();

348

Model resNet50Model = resNet50.init();

349

```

350

351

**Custom Configuration:**

352

353

```java

354

// Custom number of classes for your dataset

355

int numClasses = 10; // e.g., for CIFAR-10

356

VGG16 customVGG16 = new VGG16(numClasses, 123, 1, WorkspaceMode.SINGLE);

357

358

// Get input requirements

359

ModelMetaData metadata = customVGG16.metaData();

360

int[][] inputShape = metadata.getInputShape(); // [3, 224, 224]

361

```

362

363

**Pre-trained Models:**

364

365

```java

366

// Load pre-trained weights

367

VGG16 vgg16 = new VGG16(1000, 42, 1);

368

Model pretrainedModel = vgg16.initPretrained(PretrainedType.IMAGENET);

369

370

// Check what pre-trained weights are available

371

boolean hasImageNet = vgg16.pretrainedAvailable(PretrainedType.IMAGENET);

372

```