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)
      ImageArtUtil.load(log, contentUrl, resolution)
      val canvas = new AtomicReference[Tensor](null)
      // Execute the main process while registered with the site index
      val registration = registerWithIndexJPG(canvas.get())
      try {
        // 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_4e,
            Inception5H.Inc5H_5a,
            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>

Code from BasicOptimizer.scala:75 executed in 548.93 seconds (2.377 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: 966373134634500
    Reset training subject: 966382212153800
    Adding measurement 65cf4d6d to history. Total: 0
    LBFGS Accumulation History: 1 points
    Constructing line search parameters: GD+Trust
    th(0)=-3.031744920694796;dx=-1.3007266690953929E-5
    Armijo: th(2.154434690031884)=-3.0317445642946934; dx=-1.3005675986596253E-5 evalInputDelta=-3.5640010276338785E-7
    Armijo: th(1.077217345015942)=-3.031744823173947; dx=-1.3007150636387308E-5 evalInputDelta=-9.752084917380444E-8
    Armijo: th(0.3590724483386473)=-3.031744920694796; dx=-1.3007299934189033E-5 evalInputDelta=0.0
    Armijo: th(0.08976811208466183)=-3.031744920694796; dx=-1.300726687832166E-5 evalInputDelta=0.0
    Armijo: th(0.017953622416932366)=-3.031744920694796; dx=-1.3007266812933546E-5 evalInputDelta=0.0
    Armijo: th(0.002992270402822061)=-3.031744920694796; dx=-1.3007266654206902E-5 evalInputDelta=0.0
    Armijo: th(4.2746720040315154E-4)=-3.031744920694796; dx=-1.3007266703497736E-5 evalInputDelta=0.0
    Armijo: th(5.343340005039394E-5)=-3.031744920694796; dx=-1.300726673560978E-5 evalInputDelta=0.0
    WOLFE (weak): th(5.9370444500437714E-6)=-3.031744920694796; dx=-1.3007266662190025E-5 evalInputDelta=0.0
    Armijo: th(2.9685222250218857E-5)=-3.031744920694796; dx=-1.3007266752583963E-5 evalInputDelta=0.0
    Armijo: th(1.7811133350131314E-5)=-3.031744920694796; dx=-1.3007266728073116E-5 evalInputDelta=0.0
    WOLFE (weak): th(1.1874088900087543E-5)=-3.031744920694796; dx=-1.3007266649301351E-5 evalInputDelta=0.0
    WOLFE (weak): th(1.4842611125109429E-5)=-3.031744920694796; dx=-1.3007266728336513E-5 evalInputDelta=0.0
    WOLFE (weak): th(1.6326872237620373E-5)=-3.031744920694796; dx=-1.3007266787569039E-5 evalInputDelta=0.0
    WOLFE (weak): th(1.7069002793875844E-5)=-3.031744920694796; dx=-1.3007266760831021E-5 evalInputDelta=0.0
    Armijo: th(1.744006807200358E-5)=-3.031744920694796; dx=-1.3007266687326725E-5 evalInputDelta=0.0
    Armijo: th(1.7254535432939713E-5)=-3.031744920694796; dx=-1.300726672606977E-5 evalInputDelta=0.0
    Armijo: th(1.716176911340778E-5

...skipping 2081 bytes...

    =0.0
    Armijo: th(9.194464412907034E-5)=-3.031744920694796; dx=-1.3007266693987482E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.27501797161633E-5)=-3.031744920694796; dx=-1.3007266709592211E-5 evalInputDelta=0.0
    Armijo: th(8.734741192261683E-5)=-3.031744920694796; dx=-1.300726679142613E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.504879581939007E-5)=-3.031744920694796; dx=-1.3007266660291127E-5 evalInputDelta=0.0
    Armijo: th(8.619810387100345E-5)=-3.031744920694796; dx=-1.3007266719397361E-5 evalInputDelta=0.0
    Armijo: th(8.562344984519677E-5)=-3.031744920694796; dx=-1.3007266711039263E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.533612283229342E-5)=-3.031744920694796; dx=-1.3007266684140978E-5 evalInputDelta=0.0
    Armijo: th(8.54797863387451E-5)=-3.031744920694796; dx=-1.3007266741890299E-5 evalInputDelta=0.0
    Armijo: th(8.540795458551926E-5)=-3.031744920694796; dx=-1.3007266751454787E-5 evalInputDelta=0.0
    Armijo: th(8.537203870890634E-5)=-3.031744920694796; dx=-1.3007266734945284E-5 evalInputDelta=0.0
    Armijo: th(8.535408077059988E-5)=-3.031744920694796; dx=-1.300726670203166E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.534510180144666E-5)=-3.031744920694796; dx=-1.3007266667569829E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.534959128602326E-5)=-3.031744920694796; dx=-1.3007266680024896E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.535183602831158E-5)=-3.031744920694796; dx=-1.3007266725652169E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.535295839945574E-5)=-3.031744920694796; dx=-1.3007266656467573E-5 evalInputDelta=0.0
    WOLFE (weak): th(8.535351958502782E-5)=-3.031744920694796; dx=-1.3007266654859503E-5 evalInputDelta=0.0
    mu ~= nu (8.535351958502782E-5): th(0.0)=-3.031744920694796
    Fitness changed from -3.031744920694796 to -3.031744920694796
    Static Iteration Total: 239.7960; Orientation: 0.1382; Line Search: 209.7042
    Iteration 2 failed. Error: -3.031744920694796
    Previous Error: 0.0 -> -3.031744920694796
    Optimization terminated 2
    Final threshold in iteration 2: -3.031744920694796 (> -Infinity) after 548.918s (< 3600.000s)
    

Returns:

    -3.031744920694796