Closed mandar2812 closed 5 years ago
I see that the 0.4.0-SNAPSHOT
has not been updated since 14 October, can you update it please @eaplatanios
@mandar2812 This apply
should not be needed if you do import org.platanios.tensorflow.api._
because it is handled through implicit conversions of the form implicit def fromSupportedType[T: TF](value: T): Tensor[T]
. Does that not work for you?
Also, with respect to 0.4.0-SNAPSHOT
yes I have only updated it for Scala 2.12 because I'm trying to fix an issue. I hope this will be resolved by end-of-day today and I will update the artifacts for both Scala 2.11 and 2.12.
@eaplatanios I see, unfortunately the scala compiler complains about this. So in my source file I import the following
import java.nio.ByteBuffer
import io.github.mandar2812.dynaml.probability.RandomVariable
import org.platanios.tensorflow.api.core.types.{Half, TF}
import org.platanios.tensorflow.api._
and the following kind of code throws problems.
def tensor_i64(shape: Int*)(buffer: Long*): Tensor[Long] =
Tensor(buffer.head, buffer.tail:_*).reshape(Shape(shape:_*))
Could you change the last line to?
Tensor(buffer:_*).reshape(Shape(shape:_*))
So this works
def tensor_i32(shape: Int*)(buffer: Int*): Tensor[Int] =
Tensor[Int](buffer:_*).reshape(Shape(shape:_*))
So the implicit is being found! But Intellij Idea presentation compiler seems to disagree. But that is not an issue as the code is compiling. Thanks!
@mandar2812 Thanks for verifying it works! :) And yeah the IntelliJ presentation compiler does fail sometimes.
@eaplatanios Sorry for the wrong verification, but I was making a lot of changes to DynaML to make it compatible with tf-0.4.0, and now after all my refactors, I see the following errors.
def tensor_from[D: core.types.TF](shape: Shape)(buffer: D*): Tensor[D] = {
val t: Tensor[D] = Tensor(buffer:_*)
t.reshape(shape.toTensor)
}
error] /Users/mandar/Development/DynaML/dynaml-core/src/main/scala-2.11/io/github/mandar2812/dynaml/tensorflow/api/Api.scala:31: type mismatch;
[error] found : Seq[D]
[error] required: Seq[org.platanios.tensorflow.api.tensors.Tensor[D]]
[error] val t: Tensor[D] = Tensor(buffer:_*)
This is from command line sbt, so its not just the presentation compiler, but even the standard scala compiler does not pick up the needed implicits, the imports in the beginning of the file are
import java.nio.ByteBuffer
import io.github.mandar2812.dynaml.probability.RandomVariable
//import org.platanios.tensorflow.api.core.types.{Half, core.types.TF}
import org.platanios.tensorflow.api._
@eaplatanios Its also a bit weird that I have to explicitly specify the type for t
before reshaping it.
@eaplatanios But the following works!
def tensor_f32(shape: Int*)(buffer: Float*): Tensor[Float] =
Tensor[Float](buffer).reshape(Shape(shape:_*))
testing it in the DynaML REPL
DynaML>val t = dtf.tensor_f32(2, 2)((1 to 4).map(_.toFloat).toSeq:_*)
t: org.platanios.tensorflow.api.package.Tensor[Float] = Tensor[Float, [2, 2]]
DynaML>t.summarize()
res4: String = """Tensor[Float, [2, 2]]
[[1.0, 2.0],
[3.0, 4.0]]"""
Currently the
Tensor
object has the following methodsIts weird that there is no simple apply method.