loss_weight is the loss weight for the 'EuclideanLoss' layer output. midnet_loss_weight is the loss weight for the first 'InnerProduct' layer output. Should both default to 0.0 if unspecified (i.e., if NULL is passed to this function).
| 296 | // output. Should both default to 0.0 if unspecified (i.e., if NULL is |
| 297 | // passed to this function). |
| 298 | virtual void InitUnsharedWeightsNet(const Dtype* loss_weight = NULL, |
| 299 | const Dtype* midnet_loss_weight = NULL, |
| 300 | const bool force_backward = false, const bool bias_term = false, |
| 301 | const Dtype blobs_lr_w1 = 1, const Dtype blobs_lr_b1 = 2, |
| 302 | const Dtype blobs_lr_w2 = 1, const Dtype blobs_lr_b2 = 2) { |
| 303 | string bias_str = bias_term ? "true ":"false "; |
| 304 | ostringstream proto; |
| 305 | proto << "name: 'UnsharedWeightsNetwork' "; |
| 306 | if (force_backward) { |
| 307 | proto << "force_backward: true "; |
| 308 | } |
| 309 | proto << |
| 310 | "layer { " |
| 311 | " name: 'data' " |
| 312 | " type: 'DummyData' " |
| 313 | " dummy_data_param { " |
| 314 | " num: 5 " |
| 315 | " channels: 2 " |
| 316 | " height: 3 " |
| 317 | " width: 4 " |
| 318 | " data_filler { " |
| 319 | " type: 'gaussian' " |
| 320 | " std: 0.01 " |
| 321 | " } " |
| 322 | " } " |
| 323 | " top: 'data' " |
| 324 | "} " |
| 325 | "layer { " |
| 326 | " name: 'innerproduct1' " |
| 327 | " type: 'InnerProduct' " |
| 328 | " inner_product_param { " |
| 329 | " num_output: 10 " |
| 330 | " bias_term: " << bias_str << |
| 331 | " weight_filler { " |
| 332 | " type: 'gaussian' " |
| 333 | " std: 10 " |
| 334 | " } " |
| 335 | " } " |
| 336 | " param { " |
| 337 | " name: 'unsharedweights1' " |
| 338 | " lr_mult: " << blobs_lr_w1 << |
| 339 | " } "; |
| 340 | if (bias_term) { |
| 341 | proto << " param { lr_mult: " << blobs_lr_b1 << " } "; |
| 342 | } |
| 343 | proto << |
| 344 | " bottom: 'data' " |
| 345 | " top: 'innerproduct1' "; |
| 346 | if (midnet_loss_weight) { |
| 347 | proto << " loss_weight: " << *midnet_loss_weight << " "; |
| 348 | } |
| 349 | proto << |
| 350 | "} " |
| 351 | "layer { " |
| 352 | " name: 'innerproduct2' " |
| 353 | " type: 'InnerProduct' " |
| 354 | " inner_product_param { " |
| 355 | " num_output: 10 " |