in Education by
Is Tensorflow similar to scikit learn's one hot encoder for processing of categorical data? Does using placeholder of tf.string behave as categorical data? I can pre-process the data manaually prior sending to tensorflow, but having built in is very easy. Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
tf.one_hot is one of the functions which can convert a set of sparse labels to a dense one-hot representation, as of TensorFlow 0.8. In some cases, tf.nn.sparse_softmax_cross_entropy_with_logits can be used to calculate cross-entropy directly on sparse labels instead of converting them to one-hot.In case you want to to do in the old primitive way refer to the following code which uses sparse-to-dense operator: numLabel = 10 sprsLabel= tf.reshape(lBatch, [-1, 1]) deriveSize = tf.shape(lbatch)[0] i = tf.reshape(tf.range(0, deriveSize, 1), [-1, 1]) conc = tf.concat(1, [i, sprsLabel]) outshape = tf.pack([deriveSize, numLabel]) labels = tf.sparse_to_dense(conc, outshape, 1.0, 0.0) This gives a label as an output which is a one-hot matric having a size equal to batchsize x numLabel. Hope this answer helps. If you want to get professional experience in TensorFlow, join this Machine Learning Course.

Related questions

0 votes
    Suppose I have a Tensorflow tensor. How do I get the dimensions (shape) of the tensor as integer values? I ... 'Dimension' instead. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am new to TensorFlow. While I am reading the existing documentation, I found the term tensor really confusing. ... types of tensors? Select the correct answer from above options...
asked Jan 29, 2022 in Education by JackTerrance
0 votes
    I'm creating a very basic AI with Tensorflow, and am using the code from the official docs/tutorial. Here's my ... Tensorflow 1.13.1. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I was looking at the docs of TensorFlow about tf.nn.conv2d here. But I can't understand what it does or ... it raised the question. Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    Currently, I have Keras with TensorFlow and CUDA at the backend. But, I want to force Keras to use the ... are accessible via Keras. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have noticed that in most models step parameter is used to indicate the no. of steps to run over data ... epochs? Data shuffling? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I recently started finding out deep learning & machine learning techniques, and I started sorting out frameworks ... machine learning. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I am trying to understand the role of the Flatten function in Keras. Below is my code, which is a simple two ... flatten it? Thanks! Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I have worked all the tutorials and searched for "load csv tensorflow" but just can't get the logic of it all. ... and test the net. Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I am trying to decompose a 3D matrix using python library scikit-tensor. I managed to decompose my Tensor ... the decomposed matrices? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
0 votes
    I'm wondering how to calculate precision and recall measures for multiclass multilabel classification, i.e. classification ... labels? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    I have a Python dictionary like the following: {u'2012-06-08': 388, u'2012-06-09': 388, u'2012-06-10 ... (my_dict,index=my_dict.keys()) Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    What is the role of Flatten in Keras. I am executing the code below and it's a two layered network. The ... output is already flat? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I started Tensorflow some days back and I understand that it is a visualization tool but is there any way to ... remote Ubuntu machine? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    In tensorflow API documentation here one keyword was there logits. What is logits? In most of the documents I went ... , name=None) Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
...