tensorflow / tensorflow/java

How to convert DenseNDArray to NDArray ?

Open
#458 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
928
Forks
227
PR merge metrics
No merged PRs in 30d

Description

HI , when I read TfRecordDataset from tfrecord file , I get the data type is DenseNDArray ,actual is DenseTString, I want to convert it to TString data.

my code -scala version

    val path = "/Volumes/Pink4T/transfer/code/github/stanford-tensorflow-tutorials/2017/data/friday.tfrecord"

    val dataset =  Dataset.tfRecordDataset(tf,path,"",0l).batch(10) // readData(path) //
//    DenseNdArray
    var count =0
    for (outputs <- dataset) {
      try {
        val batch1 = outputs.get(count).asTensor.asInstanceOf[TString]
        try {

          val byteNdArray:NdArray[Array[Byte]]= batch1.asBytes().asInstanceOf[NdArray[Array[Byte]]] //ByteNdArray]
         val bda = byteNdArray.asInstanceOf[DenseNdArray[TString]] // here !!! how to get   SparseNdArray?
          println(s"bda shape ${bda.shape()} ${kk.shape()}")

          count = count + 1
        } finally {
          if (batch1 != null) batch1.close()

        }
      }
    }

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The report centers on Dataset.tfRecordDataset and the DenseNDArray, NDArray, and TString types in the Scala example. Start by tracing those APIs and the TensorFlow Java tensor-conversion documentation. Done means identifying and documenting a supported conversion path, or clearly recording that the requested conversion is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala, tensorflow
Domain
machine-learning
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.