ValueError: Can’t convert non-rectangular Python sequence to Tensor

I’m not sure whether they exist in TensorFlow 1 but TensorFlow 2.0 supports RaggedTensors, which the documentation describes as “… the TensorFlow equivalent of nested variable-length lists.” I think it would be trivial to convert your data to RaggedTensors. It might even be as easy as: data_tensor = tf.ragged.constant(data) Example: >>> a = tf.ragged.constant([[1],[2,3]]) >>> … Read more

Run Tensorflow unit tests

The easiest way to run the TensorFlow unit tests is using Bazel, assuming you have downloaded the source from Git: # All tests (for C++ changes). $ bazel test //tensorflow/… # All Python tests (for Python front-end changes). $ bazel test //tensorflow/python/… # All tests (with GPU support). $ bazel test -c opt –config=cuda //tensorflow/… … Read more

Is there any way to get variable importance with Keras?

*Edited to include relevant code to implement permutation importance. I answered a similar question at Feature Importance Chart in neural network using Keras in Python. It does implement what Teque5 mentioned above, namely shuffling the variable among your sample or permutation importance using the ELI5 package. from keras.wrappers.scikit_learn import KerasClassifier, KerasRegressor import eli5 from eli5.sklearn … Read more

ValueError: Shapes (None, 1) and (None, 3) are incompatible

The first problem is with the LSTM input_shape. input_shape = (20,85,1). From the doc: https://keras.io/layers/recurrent/ LSTM layer expects 3D tensor with shape (batch_size, timesteps, input_dim). model.add(tf.keras.layers.Dense(nb_classes, activation=’softmax’)) – this suggets you’re doing a multi-class classification. So, you need your y_train and y_test have to be one-hot-encoded. That means they must have dimension (number_of_samples, 3), where … Read more

Flatten batch in tensorflow

You can do it easily with tf.reshape() without knowing the batch size. x = tf.placeholder(tf.float32, shape=[None, 9,2]) shape = x.get_shape().as_list() # a list: [None, 9, 2] dim = numpy.prod(shape[1:]) # dim = prod(9,2) = 18 x2 = tf.reshape(x, [-1, dim]) # -1 means “all” The -1 in the last line means the whole column no … Read more

Tensorflow: Cannot interpret feed_dict key as Tensor

This worked for me from keras import backend as K and after predicting my data i inserted this part of code then i had again loaded the model. K.clear_session() i faced this problem in production server, but in my pc it was running fine ……….. from keras import backend as K #Before prediction K.clear_session() #After … Read more

You must feed a value for placeholder tensor ‘Placeholder’ with dtype float

Some questions first why you use sess = tf.InteractiveSession() and with tf.Session() as sess: at same time, just curious second what is your placeholder name x or images? if name is x, {images: x_data…} won’t feed x_data to x, it override(?) images I think feed_dict should be {x: x_data…} if name is images,do you have … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)