Categories
Mastering Development

Tensorflow with batch size and wrong dimesion

Here are my code: # Model parameters: W and b # tf.reset_default_graph() W = tf.get_variable("weight",shape = [784, 10], dtype=tf.float32) b = tf.get_variable("b", shape=(784,10), dtype= tf.float32) input_X = tf.placeholder(‘float32’, shape = (None,10)) input_y = tf.placeholder(‘float32’, [784, 10]) ogits = W*input_X + b probas = tf.nn.softmax(logits) classes = tf.argmax(probas) loss = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels = input_y, logits = logits)) […]

Categories
Mastering Development

How to show the prediction values while the neural-network training is on going

I am training a model to classify the video clips out of the two labels, while the model loss keep the same, so I am wondering the prediction values when traning is going on, I do some trying, then comes the error: Cannot assign a device for operation ‘replica_1_5/model_12/activation_7/Softmax’: Could not satisfy explicit device specification […]

Categories
Mastering Development

How to allow keras model predict function in multiple thread algorithm?

I’m trying to train a reinforcement learning(RL) agent on a custom environment. My RL agent is the stable baseline implementation of the DDPG algorithm. It uses multiple threads for training. One of the arguments for this agent is an environment, which is implemented according to Open AI gym custom environment interface. My environment needs to […]

Categories
Development

Replacing feed_dict in TF2.0 for tensor inputs to tensors in a function

I have a Keras Callback that retrieves values from particular Keras layers like so: def run(self, fetches, next_batch): “””Run fetches using the validation data passed in during initialization.””” input_data, target_data = self.sess.run(next_batch) feed_dict = {self.model.inputs[0]: input_data, self.model._targets[0]: target_data} result = self.sess.run(fetches=fetches, feed_dict=feed_dict) return result next_batch was a Dataset.make_one_shot_iterator.get_next() call in tf1. I’ve replaced it with […]

Categories
Development

Cannot feed value of shape (100,) for Tensor ‘Placeholder_1:0’, which has shape ‘(?, 1)’

Tensorflow 1.14 gives me issue “Cannot feed value of shape (100,) for Tensor ‘Placeholder_1:0’, which has shape ‘(?, 1)’” as mentioned in the question. This error occurs in the session segment of the code [last cell of the code]. How do I solve it? Im not able to understand where the bug is lying. The […]

Categories
Development

Why do I get ‘Connecting to invalid output of source node’ error with a Tensorflow-Hub KerasLayer?

Edit: I tried turning on eager execution to see if I could identify exactly where the issue was occuring, and eager execution stopped the errors and made it run successfully. No idea why that would be the case and unfortunately that really doesn’t help me. Original Post: I’m pretty new to Tensorflow and I’m trying […]