Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Feature and Deprecation Warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgk committed Apr 10, 2019
1 parent fde4963 commit 4437666
Show file tree
Hide file tree
Showing 25 changed files with 43 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.mxnet

import scala.language.implicitConversions

object MX_PRIMITIVES {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ object Symbol extends SymbolBase {

// a more friendly interface for creating symbols
// all values except symbols in kwargs will be cast to String using its toString() method
@Deprecated
@deprecated("Use Checked version", "0.1.2")
def createFromNamedSymbolsNoCheck(
operator: String, name: String = null, attr: Map[String, String] = null)(
kwargs: Map[String, Any]): Symbol = {
Expand All @@ -1208,7 +1208,7 @@ object Symbol extends SymbolBase {

// a more friendly interface for creating symbols
// all values except symbols in kwargs will be cast to String using its toString() method
@Deprecated
@deprecated("Use Checked version", "0.1.2")
def createFromListedSymbolsNoCheck(
operator: String, name: String = null, attr: Map[String, String] = null)(
symbols: Array[Symbol], kwargs: Map[String, Any] = null): Symbol = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package org.apache.mxnet.util

import scala.language.implicitConversions

object OptionConversion {
implicit def someWrapper[A](noSome : A) : Option[A] = Option(noSome)
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package org.apache.mxnet

import org.apache.mxnet.io.{NDArrayIter, ResizeIter, PrefetchingIter}
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import scala.language.postfixOps
import scala.sys.process._


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.collection.mutable.ListBuffer
import scala.language.postfixOps
import scala.sys.process._

class ConvSuite extends FunSuite with BeforeAndAfterAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ object CNNTextClassification {
// decay learning rate
if (iter % 50 == 0 && iter > 0) {
factor *= 0.5f
opt.setLrScale(paramBlocks.map(_._1 -> factor).toMap)
opt.setLrMult(paramBlocks.map(paramBlock => (Left(paramBlock._1), factor)).toMap)
logger.info(s"reset learning to ${opt.learningRate * factor}")
}
// end of training loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import org.apache.mxnet.optimizer.RMSProp
import org.apache.mxnetexamples.Util

import scala.collection.immutable.ListMap
import scala.language.postfixOps
import scala.sys.process.Process

/**
Expand Down Expand Up @@ -100,7 +101,7 @@ object ExampleMultiTask {
override def getIndex(): IndexedSeq[Long] = this.dataIter.getIndex()

// The name and shape of label provided by this iterator
@deprecated
@deprecated("Use provideLabelDesc instead", "1.3.0")
override def provideLabel: ListMap[String, Shape] = {
val provideLabel = this.dataIter.provideLabel.toArray
// Different labels should be used here for actual application
Expand All @@ -126,7 +127,7 @@ object ExampleMultiTask {
override def getPad(): Int = this.dataIter.getPad()

// The name and shape of data provided by this iterator
@deprecated
@deprecated("Use provideDataDesc instead", "1.3.0")
override def provideData: ListMap[String, Shape] = this.dataIter.provideData

override def provideDataDesc: IndexedSeq[DataDesc] = this.dataIter.provideDataDesc
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ object NeuralStyle {
private val logger = LoggerFactory.getLogger(classOf[NeuralStyle])

def preprocessContentImage(path: String, longEdge: Int, ctx: Context): NDArray = {
val img = Image(new File(path))
val img = Image.fromFile(new File(path))
logger.info(s"load the content image, size = ${(img.height, img.width)}")
val factor = longEdge.toFloat / Math.max(img.height, img.width)
val (newHeight, newWidth) = ((img.height * factor).toInt, (img.width * factor).toInt)
Expand All @@ -60,7 +60,7 @@ object NeuralStyle {
}

def preprocessStyleImage(path: String, shape: Shape, ctx: Context): NDArray = {
val img = Image(new File(path))
val img = Image.fromFile(new File(path))
val resizedImg = img.scaleTo(shape(3), shape(2))
val sample = NDArray.empty(Shape(1, 3, shape(2), shape(3)), ctx)
val datas = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ object DataProcessing {

def preprocessContentImage(path: String,
dShape: Shape = null, ctx: Context): NDArray = {
val img = Image(new File(path))
val img = Image.fromFile(new File(path))
val resizedImg = img.scaleTo(dShape(3), dShape(2))
val sample = NDArray.empty(Shape(1, 3, resizedImg.height, resizedImg.width), ctx)
val datas = {
Expand All @@ -46,7 +46,7 @@ object DataProcessing {
}

def preprocessStyleImage(path: String, shape: Shape, ctx: Context): NDArray = {
val img = Image(new File(path))
val img = Image.fromFile(new File(path))
val resizedImg = img.scaleTo(shape(3), shape(2))
val sample = NDArray.empty(Shape(1, 3, shape(2), shape(3)), ctx)
val datas = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ object BucketIo {
override def getPad(): Int = 0

// The name and shape of label provided by this iterator
@deprecated
@deprecated("Use provideLabelDesc instead", "1.3.0")
override def provideLabel: ListMap[String, Shape] = this._provideLabel

// The name and shape of data provided by this iterator
@deprecated
@deprecated("Use provideDataDesc instead", "1.3.0")
override def provideData: ListMap[String, Shape] = this._provideData

// Provide type:DataDesc of the data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

class ScalaInferenceBenchmarkSuite extends FunSuite with BeforeAndAfterAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

class CustomOpExampleSuite extends FunSuite with BeforeAndAfterAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite, Ignore}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

class GanExampleSuite extends FunSuite with BeforeAndAfterAll{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import java.io.File
import org.apache.mxnet.Context
import org.apache.mxnetexamples.Util

import scala.language.postfixOps
import sys.process.Process

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

class ObjectDetectorExampleSuite extends FunSuite with BeforeAndAfterAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.apache.mxnetexamples.neuralstyle.end2end.{BoostInference, BoostTrain}
import org.scalatest.{BeforeAndAfterAll, FunSuite}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.apache.mxnetexamples.Util
import org.scalatest.{BeforeAndAfterAll, FunSuite, Ignore}
import org.slf4j.LoggerFactory

import scala.language.postfixOps
import scala.sys.process.Process

class ExampleRNNSuite extends FunSuite with BeforeAndAfterAll {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class ClassifierSuite extends FunSuite with BeforeAndAfterAll {
val result: IndexedSeq[(String, Double)] = testClassifier.
classify(IndexedSeq(inputData), topK = Some(10))

assert((result(0)_2).getClass == 1d.getClass)
assert((result(0)._2).getClass == 1d.getClass)

assertResult(predictResult(0).sortBy(-_)) {
result.map(_._2).toArray
Expand Down Expand Up @@ -185,7 +185,7 @@ class ClassifierSuite extends FunSuite with BeforeAndAfterAll {
val result: IndexedSeq[(String, Double)] = testClassifier.
classify(IndexedSeq(inputData))

assert((result(0)_2).getClass == 1d.getClass)
assert((result(0)._2).getClass == 1d.getClass)

assertResult(predictResult(0)) {
result.map(_._2).toArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private[mxnet] abstract class GeneratorBase {
throw new IllegalArgumentException(s"Invalid macro input: $ex")
}
// wrap the result up in an Expr, and return it
val result = c.Expr(Block(modDefs, Literal(Constant())))
val result = c.Expr(Block(modDefs, Literal(Constant(()))))
result
}

Expand Down
8 changes: 8 additions & 0 deletions scala-package/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@
<version>2.1.0</version>
</compilerPlugin>
</compilerPlugins>
<args>
<arg>-feature</arg>
<arg>-deprecation</arg>
</args>
</configuration>
<executions>
<execution>
Expand All @@ -366,6 +370,10 @@
<artifactId>scala-maven-plugin</artifactId>
<version>3.3.2</version>
<configuration>
<args>
<arg>-feature</arg>
<arg>-deprecation</arg>
</args>
</configuration>
<executions>
<execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ class LabeledPointIter private[mxnet](
}

// The name and shape of label provided by this iterator
@deprecated
@deprecated("Use provideLabelDesc instead", "1.3.0")
override def provideLabel: ListMap[String, Shape] = {
ListMap(labelName -> Shape(_batchSize))
}

// The name and shape of data provided by this iterator
@deprecated
@deprecated("Use provideDataDesc instead", "1.3.0")
override def provideData: ListMap[String, Shape] = {
ListMap(dataName -> dataShape)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ class PointIter private[mxnet](
}

// The name and shape of label provided by this iterator
@deprecated
@deprecated("Use provideLabelDesc instead", "1.3.0")
override def provideLabel: ListMap[String, Shape] = {
ListMap(labelName -> Shape(_batchSize))
}

// The name and shape of data provided by this iterator
@deprecated
@deprecated("Use provideDataDesc instead", "1.3.0")
override def provideData: ListMap[String, Shape] = {
ListMap(dataName -> dataShape)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.apache.mxnet.spark
import java.io.{BufferedReader, File, InputStreamReader}
import java.nio.file.Files

import scala.language.postfixOps
import scala.sys.process.Process

import org.apache.spark.SparkContext
Expand Down

0 comments on commit 4437666

Please sign in to comment.