or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

components.mdindex.mdremote-monitoring.mdstatistics.mdstorage.mdui-server.md

remote-monitoring.mddocs/

0

# Remote Monitoring

1

2

The remote monitoring system enables distributed training scenarios where training occurs on remote machines while the UI runs on a different machine. This is particularly useful for cluster computing environments and cloud-based training setups.

3

4

## Core Remote Monitoring API

5

6

### WebReporter

7

8

Background web reporting system for sending training updates to remote UI servers.

9

10

```java { .api }

11

public class WebReporter {

12

// Singleton access

13

public static WebReporter getInstance();

14

15

// Asynchronous reporting (queues for background processing)

16

public void queueReport(WebTarget target, Entity entity);

17

18

// Synchronous reporting (immediate POST request)

19

public void postReport(WebTarget target, Entity entity);

20

}

21

```

22

23

**Important Note**: The current WebReporter implementation throws `RuntimeException("Not implemented")` in the constructor, indicating this class is not fully functional in version 0.9.1. Use remote iteration listeners or remote storage routers instead for reliable remote monitoring.

24

25

## Remote Iteration Listeners

26

27

### RemoteHistogramIterationListener

28

29

Remote version of the histogram iteration listener for weight and gradient visualization.

30

31

```java { .api }

32

public class RemoteHistogramIterationListener implements IterationListener {

33

// Constructors

34

public RemoteHistogramIterationListener(String serverAddress);

35

public RemoteHistogramIterationListener(String serverAddress, int frequency);

36

public RemoteHistogramIterationListener(String serverAddress, int frequency,

37

HttpClientBuilder httpClientBuilder);

38

39

// Configuration

40

public void setStorageRouter(StatsStorageRouter router);

41

public void setFrequency(int frequency);

42

43

// Lifecycle

44

public void iterationDone(Model model, int iteration, int epoch);

45

}

46

```

47

48

### RemoteFlowIterationListener

49

50

Remote version of the flow iteration listener for network architecture visualization.

51

52

```java { .api }

53

public class RemoteFlowIterationListener implements IterationListener {

54

// Constructors

55

public RemoteFlowIterationListener(String serverAddress);

56

public RemoteFlowIterationListener(String serverAddress, int frequency);

57

public RemoteFlowIterationListener(String serverAddress, int frequency,

58

HttpClientBuilder httpClientBuilder);

59

60

// Configuration

61

public void setCollectActivations(boolean collect);

62

public void setCollectGradients(boolean collect);

63

public void setFrequency(int frequency);

64

65

// Lifecycle

66

public void iterationDone(Model model, int iteration, int epoch);

67

}

68

```

69

70

### RemoteConvolutionalIterationListener

71

72

Remote version of the convolutional iteration listener for CNN-specific visualizations.

73

74

```java { .api }

75

public class RemoteConvolutionalIterationListener implements IterationListener {

76

// Constructors

77

public RemoteConvolutionalIterationListener(String serverAddress);

78

public RemoteConvolutionalIterationListener(String serverAddress, int frequency);

79

public RemoteConvolutionalIterationListener(String serverAddress, int frequency,

80

HttpClientBuilder httpClientBuilder);

81

82

// Configuration

83

public void setCollectActivations(boolean collect);

84

public void setCollectionLayers(List<String> layerNames);

85

public void setFrequency(int frequency);

86

87

// Lifecycle

88

public void iterationDone(Model model, int iteration, int epoch);

89

}

90

```

91

92

## Remote Storage Configuration

93

94

### RemoteUIStatsStorageRouter

95

96

Router for sending statistics to remote UI servers.

97

98

```java { .api }

99

public class RemoteUIStatsStorageRouter implements StatsStorageRouter {

100

// Constructors

101

public RemoteUIStatsStorageRouter(String serverAddress);

102

public RemoteUIStatsStorageRouter(String serverAddress, HttpClientBuilder httpClientBuilder);

103

104

// StatsStorageRouter implementation

105

public void putStaticInfo(Persistable staticInfo);

106

public void putUpdate(Persistable update);

107

public void putStorageMetaData(StorageMetaData storageMetaData);

108

109

// Configuration

110

public void setServerAddress(String address);

111

public String getServerAddress();

112

}

113

```

114

115

### Connection Configuration

116

117

Configuration classes for remote connections.

118

119

```java { .api }

120

public class UiConnectionInfo {

121

// Connection details

122

private String address;

123

private int port;

124

private String protocol;

125

private String path;

126

127

// Constructors

128

public UiConnectionInfo(String address);

129

public UiConnectionInfo(String address, int port);

130

public UiConnectionInfo(String protocol, String address, int port, String path);

131

132

// Accessors

133

public String getAddress();

134

public int getPort();

135

public String getProtocol();

136

public String getPath();

137

public String getFullAddress();

138

}

139

```

140

141

## Usage Examples

142

143

### Basic Remote Training Setup

144

145

```java

146

import org.deeplearning4j.ui.weights.RemoteHistogramIterationListener;

147

import org.deeplearning4j.ui.flow.RemoteFlowIterationListener;

148

149

// Configure remote UI server address

150

String uiServerAddress = "http://ui-server:9000";

151

152

// Create remote listeners

153

RemoteHistogramIterationListener histogramListener =

154

new RemoteHistogramIterationListener(uiServerAddress, 10);

155

156

RemoteFlowIterationListener flowListener =

157

new RemoteFlowIterationListener(uiServerAddress, 50);

158

159

// Attach to model

160

MultiLayerNetwork model = new MultiLayerNetwork(config);

161

model.init();

162

model.setListeners(histogramListener, flowListener);

163

164

// Train model - data will be sent to remote UI server

165

model.fit(trainingData);

166

```

167

168

### Custom HTTP Client Configuration

169

170

```java

171

import org.apache.http.impl.client.HttpClientBuilder;

172

import org.apache.http.client.config.RequestConfig;

173

174

// Configure HTTP client with custom timeouts

175

RequestConfig requestConfig = RequestConfig.custom()

176

.setConnectTimeout(5000)

177

.setSocketTimeout(10000)

178

.setConnectionRequestTimeout(5000)

179

.build();

180

181

HttpClientBuilder httpClientBuilder = HttpClientBuilder.create()

182

.setDefaultRequestConfig(requestConfig)

183

.setMaxConnTotal(10)

184

.setMaxConnPerRoute(5);

185

186

// Create remote listener with custom HTTP client

187

RemoteHistogramIterationListener listener = new RemoteHistogramIterationListener(

188

uiServerAddress, 10, httpClientBuilder);

189

190

model.setListeners(listener);

191

```

192

193

### Remote Storage Router

194

195

```java

196

import org.deeplearning4j.api.storage.impl.RemoteUIStatsStorageRouter;

197

import org.deeplearning4j.ui.stats.StatsListener;

198

199

// Create remote storage router

200

RemoteUIStatsStorageRouter remoteRouter =

201

new RemoteUIStatsStorageRouter("http://ui-server:9000");

202

203

// Use with standard StatsListener for modern approach

204

StatsListener statsListener = new StatsListener(remoteRouter);

205

206

model.setListeners(statsListener);

207

```

208

209

### Multiple Remote Targets

210

211

```java

212

// Send data to multiple UI servers

213

String[] uiServers = {

214

"http://ui-server-1:9000",

215

"http://ui-server-2:9000",

216

"http://backup-ui-server:9000"

217

};

218

219

List<RemoteHistogramIterationListener> remoteListeners = new ArrayList<>();

220

221

for (String serverAddress : uiServers) {

222

RemoteHistogramIterationListener listener =

223

new RemoteHistogramIterationListener(serverAddress, 10);

224

remoteListeners.add(listener);

225

}

226

227

// Add all remote listeners to model

228

model.setListeners(remoteListeners.toArray(new IterationListener[0]));

229

```

230

231

### Secure Remote Connections

232

233

```java

234

import javax.net.ssl.SSLContext;

235

import org.apache.http.conn.ssl.SSLConnectionSocketFactory;

236

237

// Configure SSL for secure connections

238

SSLContext sslContext = SSLContext.getDefault();

239

SSLConnectionSocketFactory sslConnectionFactory =

240

new SSLConnectionSocketFactory(sslContext);

241

242

HttpClientBuilder secureClientBuilder = HttpClientBuilder.create()

243

.setSSLSocketFactory(sslConnectionFactory);

244

245

// Create secure remote listener

246

RemoteHistogramIterationListener secureListener = new RemoteHistogramIterationListener(

247

"https://secure-ui-server:9443", 10, secureClientBuilder);

248

249

model.setListeners(secureListener);

250

```

251

252

### Error Handling and Retry Logic

253

254

```java

255

import org.deeplearning4j.ui.WebReporter;

256

import javax.ws.rs.client.WebTarget;

257

import javax.ws.rs.client.Entity;

258

259

// Custom reporter with error handling

260

WebReporter reporter = WebReporter.getInstance();

261

262

// Queue reports with automatic retry

263

try {

264

reporter.queueReport(webTarget, entity);

265

} catch (Exception e) {

266

// Handle network errors

267

System.err.println("Failed to send report: " + e.getMessage());

268

269

// Implement retry logic or fallback storage

270

// ... retry or store locally for later transmission

271

}

272

```

273

274

### Conditional Remote Reporting

275

276

```java

277

// Enable remote reporting only in certain environments

278

String environment = System.getProperty("environment", "local");

279

boolean enableRemoteReporting = "production".equals(environment) || "staging".equals(environment);

280

281

if (enableRemoteReporting) {

282

String uiServerAddress = System.getProperty("ui.server.address", "http://localhost:9000");

283

284

RemoteHistogramIterationListener remoteListener =

285

new RemoteHistogramIterationListener(uiServerAddress, 10);

286

287

model.setListeners(remoteListener);

288

} else {

289

// Use local UI server for development

290

UIServer localServer = UIServer.getInstance();

291

InMemoryStatsStorage localStorage = new InMemoryStatsStorage();

292

localServer.attach(localStorage);

293

294

StatsListener localListener = new StatsListener(localStorage);

295

model.setListeners(localListener);

296

}

297

```

298

299

### Remote Connection Information

300

301

```java

302

import org.deeplearning4j.ui.UiConnectionInfo;

303

304

// Create connection info

305

UiConnectionInfo connectionInfo = new UiConnectionInfo("ui-server", 9000);

306

307

// Or with full configuration

308

UiConnectionInfo fullConnectionInfo = new UiConnectionInfo(

309

"https", "ui-server", 9443, "/ui/monitoring");

310

311

// Use with remote listeners

312

RemoteHistogramIterationListener listener =

313

new RemoteHistogramIterationListener(fullConnectionInfo.getFullAddress());

314

```

315

316

### Batch Remote Updates

317

318

```java

319

import org.deeplearning4j.ui.WebReporter;

320

321

// Configure batch reporting for efficiency

322

WebReporter reporter = WebReporter.getInstance();

323

324

// Queue multiple reports - they will be sent in background

325

for (int i = 0; i < trainingBatches.size(); i++) {

326

// Train batch

327

model.fit(trainingBatches.get(i));

328

329

// Reports are automatically queued by remote listeners

330

// and sent asynchronously to avoid blocking training

331

}

332

```

333

334

## Network Architecture Considerations

335

336

### Firewall Configuration

337

338

Ensure the following ports are accessible:

339

- UI Server: Default port 9000 (configurable)

340

- HTTP/HTTPS traffic from training machines to UI server

341

- Consider using reverse proxy for production deployments

342

343

### Load Balancing

344

345

For high-availability setups:

346

- Deploy multiple UI server instances

347

- Use load balancer to distribute traffic

348

- Configure remote listeners with load balancer address

349

350

### Security Considerations

351

352

- Use HTTPS for production deployments

353

- Implement authentication/authorization as needed

354

- Consider VPN or private networks for sensitive training data

355

- Monitor network traffic and implement rate limiting if necessary