1. DeepDream

DeepDream

Implements the DeepDream image processing algorithm:
  1. Start from an input image
  2. Use the final layer of an inception network
  3. Operator to maximize RMS signal
  4. Single resolution

Code from DeepDream.scala:60 executed in 0.00 seconds (0.000 gc):

      implicit val _ = log
      // First, basic configuration so we publish to our s3 site
      log.setArchiveHome(URI.create(s"s3://$s3bucket/${getClass.getSimpleName.stripSuffix("$")}/${log.getId}/"))
      log.onComplete(() => upload(log): Unit)
      // Fetch input image (user upload prompt) and display a rescaled copies
      log.p(log.jpg(ImageArtUtil.load(log, contentUrl, resolution), "Input Content"))
      val canvas = new AtomicReference[Tensor](null)
      // Execute the main process while registered with the site index
      val registration = registerWithIndexJPG(canvas.get())
      try {
        // Display an additional image inside the report itself
        withMonitoredJpg(() => canvas.get().toImage) {
          // In contrast to other uses, in this painting operation we are enhancing
          // an input image (content) only, with no other inputs or canvas preparation.
          paint(contentUrl, contentUrl, canvas, new VisualStyleNetwork(
            styleLayers = List(
              // DeepDream traditionally uses the last layer of an inception network
              Inception5H.Inc5H_5b
            ),
            styleModifiers = List(
              // This operator increases the RMS power of any signal
              new ChannelPowerEnhancer()
            ),
            styleUrl = List(contentUrl)
          ), new BasicOptimizer {
            override val trainingMinutes: Int = 60
            override val trainingIterations: Int = 20
            override val maxRate = 1e9
          }, new GeometricSequence {
            override val min: Double = resolution
            override val max: Double = resolution
            override val steps = 1
          }.toStream.map(_.round.toDouble): _*)
        }
        null
      } finally {
        registration.foreach(_.stop()(s3client, ec2client))
      }
    }

Returns:

    <function0>

Input Content

Code from BasicOptimizer.scala:75 executed in 520.38 seconds (3.114 gc):

    val lineSearchInstance: LineSearchStrategy = lineSearchFactory
    IterativeTrainer.wrap(trainable)
      .setOrientation(orientation())
      .setMonitor(new TrainingMonitor() {
        override def clear(): Unit = trainingMonitor.clear()
  
        override def log(msg: String): Unit = trainingMonitor.log(msg)
  
        override def onStepFail(currentPoint: Step): Boolean = {
          BasicOptimizer.this.onStepFail(trainable, currentPoint)
        }
  
        override def onStepComplete(currentPoint: Step): Unit = {
          if (0 < logEvery && (0 == currentPoint.iteration % logEvery || currentPoint.iteration < logEvery)) {
            val image = currentImage
            timelineAnimation += image
            val caption = "Iteration " + currentPoint.iteration
            out.p(caption + "\n" + out.jpg(image, caption))
          }
          BasicOptimizer.this.onStepComplete(trainable, currentPoint)
          trainingMonitor.onStepComplete(currentPoint)
          super.onStepComplete(currentPoint)
        }
      })
      .setTimeout(trainingMinutes, TimeUnit.MINUTES)
      .setMaxIterations(trainingIterations)
      .setLineSearchFactory((_: CharSequence) => lineSearchInstance)
      .setTerminateThreshold(java.lang.Double.NEGATIVE_INFINITY)
      .runAndFree
      .asInstanceOf[lang.Double]

Logging:

    Reset training subject: 965641595256900
    Reset training subject: 965653725268100
    Adding measurement 468173fa to history. Total: 0
    LBFGS Accumulation History: 1 points
    Constructing line search parameters: GD+Trust
    th(0)=-1.028030033477078;dx=-4.3434994901491045E-6
    Armijo: th(2.154434690031884)=-1.028030033477078; dx=-4.3434803203481015E-6 evalInputDelta=0.0
    Armijo: th(1.077217345015942)=-1.028030033477078; dx=-4.343516628477115E-6 evalInputDelta=0.0
    Armijo: th(0.3590724483386473)=-1.028030033477078; dx=-4.343494564738786E-6 evalInputDelta=0.0
    Armijo: th(0.08976811208466183)=-1.028030033477078; dx=-4.34349950702425E-6 evalInputDelta=0.0
    Armijo: th(0.017953622416932366)=-1.028030033477078; dx=-4.343499493121147E-6 evalInputDelta=0.0
    Armijo: th(0.002992270402822061)=-1.028030033477078; dx=-4.343499495765685E-6 evalInputDelta=0.0
    Armijo: th(4.2746720040315154E-4)=-1.028030033477078; dx=-4.343499500776983E-6 evalInputDelta=0.0
    Armijo: th(5.343340005039394E-5)=-1.028030033477078; dx=-4.343499505510363E-6 evalInputDelta=0.0
    WOLFE (weak): th(5.9370444500437714E-6)=-1.028030033477078; dx=-4.343499498830599E-6 evalInputDelta=0.0
    Armijo: th(2.9685222250218857E-5)=-1.028030033477078; dx=-4.343499489733585E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.7811133350131314E-5)=-1.028030033477078; dx=-4.343499518430602E-6 evalInputDelta=0.0
    WOLFE (weak): th(2.3748177800175086E-5)=-1.028030033477078; dx=-4.343499504448482E-6 evalInputDelta=0.0
    Armijo: th(2.671670002519697E-5)=-1.028030033477078; dx=-4.343499504190053E-6 evalInputDelta=0.0
    WOLFE (weak): th(2.5232438912686027E-5)=-1.028030033477078; dx=-4.34349950636888E-6 evalInputDelta=0.0
    Armijo: th(2.5974569468941498E-5)=-1.028030033477078; dx=-4.343499518816332E-6 evalInputDelta=0.0
    Armijo: th(2.5603504190813762E-5)=-1.028030033477078; dx=-4.343499514918724E-6 evalInputDelta=0.0
    WOLFE (weak): th(2.5417971551749896E-5)=-1.028030033477078; dx=-4.343499490229629E-6 evalInputDelta=0.0
    WOLFE (weak): th(2.5510737871281828E-5)=-1.028030033477078; dx=-4.343499493115181E-6

...skipping 1925 bytes...

    ta=0.0
    Armijo: th(1.3767189985783632E-4)=-1.028030033477078; dx=-4.343499522339569E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.239047098720527E-4)=-1.028030033477078; dx=-4.3434995223436995E-6 evalInputDelta=0.0
    Armijo: th(1.307883048649445E-4)=-1.028030033477078; dx=-4.3434995225997745E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.2734650736849858E-4)=-1.028030033477078; dx=-4.343499522027388E-6 evalInputDelta=0.0
    Armijo: th(1.2906740611672154E-4)=-1.028030033477078; dx=-4.3434995126044E-6 evalInputDelta=0.0
    Armijo: th(1.2820695674261006E-4)=-1.028030033477078; dx=-4.343499519801578E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.2777673205555432E-4)=-1.028030033477078; dx=-4.343499524093373E-6 evalInputDelta=0.0
    Armijo: th(1.279918443990822E-4)=-1.028030033477078; dx=-4.343499550085724E-6 evalInputDelta=0.0
    Armijo: th(1.2788428822731824E-4)=-1.028030033477078; dx=-4.343499500402357E-6 evalInputDelta=0.0
    Armijo: th(1.2783051014143628E-4)=-1.028030033477078; dx=-4.343499531480149E-6 evalInputDelta=0.0
    Armijo: th(1.278036210984953E-4)=-1.028030033477078; dx=-4.343499497390222E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.277901765770248E-4)=-1.028030033477078; dx=-4.343499519405928E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.2779689883776003E-4)=-1.028030033477078; dx=-4.3434995103509E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.2780025996812766E-4)=-1.028030033477078; dx=-4.343499485643548E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.2780194053331148E-4)=-1.028030033477078; dx=-4.343499536411979E-6 evalInputDelta=0.0
    WOLFE (weak): th(1.2780278081590338E-4)=-1.028030033477078; dx=-4.343499500332002E-6 evalInputDelta=0.0
    mu ~= nu (1.2780278081590338E-4): th(0.0)=-1.028030033477078
    Fitness changed from -1.028030033477078 to -1.028030033477078
    Static Iteration Total: 239.4098; Orientation: 0.1342; Line Search: 220.5163
    Iteration 2 failed. Error: -1.028030033477078
    Previous Error: 0.0 -> -1.028030033477078
    Optimization terminated 2
    Final threshold in iteration 2: -1.028030033477078 (> -Infinity) after 520.367s (< 3600.000s)
    

Returns:

    -1.028030033477078