Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Adam Pocock
    @Craigacp
    1.x API. The tests in the TensorFlow Java repo are the most up to date way of doing things. Note at the moment there's an issue with gradient determinism when building models for training that causes incorrect outputs occasionally.
    We are working on a higher level API, but it's not all available yet
    Hanns Holger Rutz
    @Sciss
    thanks. I think with a bit of Scala facade, this already looks quite nice and concise.
    Hanns Holger Rutz
    @Sciss
    Is it possible to use keras API, e.g. https://www.tensorflow.org/tutorials/generative/dcgan ? or do I have to translate that back to plain TF ?
    Adam Pocock
    @Craigacp
    We're working on the higher level API, which will be Keras like, but the model and layer apis are not integrated yet.
    Hanns Holger Rutz
    @Sciss
    Ok, I'm trying to update an older keras wrapper project, it uses the old Java API. What this the new way of writing Tensors.create(float[][])?
    Hanns Holger Rutz
    @Sciss
    I can create 1D vector with TFloat32.vectorOf, but 2D?
    Tensor.of(TFloat32.class, Shape.of(javaArray.length, javaArray[0].length), data -> StdArrays.copyTo(javaArray, data)) I guess ... ? Is there a utility function that does this?
    Hanns Holger Rutz
    @Sciss

    I'm stuck with these:

    public class Ones {
        public <T extends TNumber> Operand<T> initialize(Ops tf, Operand<TInt32> shape, Class<T> dtype) {
            return tf.fill(shape, tf.constant(1.0f, dtype));   // no such method
        }
    }

    How can I convert from a float to a TNumber? In Scala this would be a type class instance TNumbers[T <: TNumber] { def fromFloat(f: Float): Operand[T] }, but I don't know how to express that in Java. Should I change Class<T> for something that has factory capabilities?

    Adam Pocock
    @Craigacp
    Off the top of my head you could use tf.cast.
    Karl Lessard
    @karllessard

    To create a 2D tensor from a 2D java array, you can invoke TFloat32.tensorOf(StdArrays.ndCopyOf(javaArray)).

    If you are looking to create a constant though, there is a shortcut function that allows you to do simply tf.constant(javaArray)

    If you can avoid completely the use of standard Java arrays and only rely on the NdArray hierarchy from the start, you’ll have better performances and memory usage
    Hanns Holger Rutz
    @Sciss
    I see, thanks. For now, I'm just trying to make somebody else's library compile ;)
    This does compile indeed tf.fill(shape, tf.dtypes.cast(tf.constant(1.0f), dtype)). So it won't fail at runtime?
    raftaa
    @raftaa
    Hi, I have a question concerning saving/exporting/loading a model for deployment. I think I want something like a frozen graph of my model i.e. one single pb file. I used tf.io.write_graph in python to write my model into a pb file. However when trying to load it in Java via SavedModelLoader.loader(pb_file_directory) I get an exception: "Could not find meta graph def matching supplied tags: { serve }. To inspect available tag-sets in the SavedModel, please use the SavedModel CLI: saved_model_cli". And saved_model_cli tells me that "SavedModel file does not exist" in that directory. I'm confused and my question is: how is this usually done and what works for TF java?
    Adam Pocock
    @Craigacp
    If you've got a frozen graph you can load that directly by reading it into a GraphDef and supplying that to the Graph before making a session. That's not how TF 2 (or even later versions of TF 1) do deployment, they use SavedModels which is a folder containing a graph pb and a checkpoint pb of the variables.
    TF-Java uses SavedModelBundle to load in saved models.
    raftaa
    @raftaa
    I understand. Thanks Adam!
    Hanns Holger Rutz
    @Sciss

    Trying to translate this tutorial. Python:

    noise = tf.random.normal([1, 100])

    How do I write that in Java/Scala? I try

    val noise = tf.random.randomStandardNormal(Shape.of(1, 100), classOf[TFloat32])

    But this is not an Operand[? <: TNumber]. How I get from Shape to that?

    Is tf.constant(Array(1, 100)) correct?
    raftaa
    @raftaa
    Hi there. I've a question again: I want to use mask_rcnn_inception_resnet_v2_1024x1024_coco17_gpu-8 from the TF2 model zoo for semantic image segmantation. I trained the CNN with python tools and now I'm trying to get the masks in our JVM inference implementation. I wonder if I can use the implementation for the "normal" FasterRCNN resulting to BBoxes. Are the masks available in the outputTensorMap? There is a key "mask_prediction" with a Tensor of shape [100, 4, 33, 33] which looks promising. Am I on the right track? How is it thought to access the masks in the java world?
    Adam Pocock
    @Craigacp
    TF-Java will return tensors the same way the model would in Python, so it should have an equivalent output with equivalent meaning.
    Jakob Sultan Ericsson
    @jakeri
    I saw that you merged 2.7 to master. Will there be a release soon?
    Karl Lessard
    @karllessard
    We are experimenting some issues with the GPU build on Linux, as soon as this is fixed and the tests are conclusive, we’ll release it
    f
    @SidneyLann
    java-tf still has no automatic derivation?
    Karl Lessard
    @karllessard
    You mean automatic differentiation? Yes there is, check at the optimizers in tensorflow-framework, is it what you are looking for?
    Karl Lessard
    @karllessard
    But if you mean gradient tape (in eager mode), this is still lacking, as the TF core lib does not expose yet what we need to support it
    f
    @SidneyLann
    What's the different? I want to do automatic BP.
    Karl Lessard
    @karllessard
    If you build a graph and want to train with automatic BP, the optimizers I’ve pointed at will do the job for you, check here for an example.
    Gradient tapes are used to calculate loss in eager mode (i.e. without graphs). If you use a graph, you are good to go.
    f
    @SidneyLann
    Ok. Thanks.
    Peter
    @phydesmith
    Hello!
    Is it ok to ask questions regarding the TF java api here?
    Karl Lessard
    @karllessard
    of course!
    Peter
    @phydesmith
    Hi Karl, thanks - I know you've helped me on my issue regarding converting buffered images to tensors on github, so I'm glad you're here. I have been working on it again in the last few weeks and have a few follow on questions.
    I'm not sure if you remember, but you posted some code that basically did some pre-processing on the buffered image bytes before putting them into the Tensor.
    Peter
    @phydesmith
    yes, exactly that
    Karl Lessard
    @karllessard
    If it is related to that, I’ll suggest that you post your questions in the forum for visibility to a larger audience, wdyt?
    could be in this same thread
    Peter
    @phydesmith
    like on that thread you linked?
    Karl Lessard
    @karllessard
    yes
    so other users looking at this thread and having the same questions as you will see the answer (hopefully :) )
    Peter
    @phydesmith
    sure I can do that, I'll post it there
    Karl Lessard
    @karllessard
    Thanks Peter
    Anton Khodakivskiy
    @akhodakivskiy
    Hello, is there Java integration for TensorBoard (if such thing is possible)? Basically I'm looking to log some data to TensorBoard from JVM
    Karl Lessard
    @karllessard
    that was on TF 1.x, but look at the Summary ops used everywhere. Again, there must be a better way for doing this.
    Actually I think that should be a main topic for our SIG meeting this Friday, I think it is important at this stage to have a clean way to support TensorBoard logging.