TensorFlow: questions regarding tf.argmax() and tf.equal()

tf.argmax(input, axis=None, name=None, dimension=None) Returns the index with the largest value across axis of a tensor. input is a Tensor and axis describes which axis of the input Tensor to reduce across. For vectors, use axis = 0. For your specific case let’s use two arrays and demonstrate this pred = np.array([[31, 23, 4, 24, … Read more

What does backbone mean in a neural network?

In my understanding, the “backbone” refers to the feature extracting network which is used within the DeepLab architecture. This feature extractor is used to encode the network’s input into a certain feature representation. The DeepLab framework “wraps” functionalities around this feature extractor. By doing so, the feature extractor can be exchanged and a model can … Read more

ResNet: 100% accuracy during training, but 33% prediction accuracy with the same data

It’s because of the batch normalization layers. In training phase, the batch is normalized w.r.t. its mean and variance. However, in testing phase, the batch is normalized w.r.t. the moving average of previously observed mean and variance. Now this is a problem when the number of observed batches is small (e.g., 5 in your example) … Read more

How to work with multiple inputs for LSTM in Keras?

Change a = dataset[i:(i + look_back), 0] To a = dataset[i:(i + look_back), :] If you want the 3 features in your training data. Then use model.add(LSTM(4, input_shape=(look_back,3))) To specify that you have look_back time steps in your sequence, each with 3 features. It should run EDIT : Indeed, sklearn.preprocessing.MinMaxScaler()‘s function : inverse_transform() takes an … Read more

tensorflow:Your input ran out of data

To make sure that you have “at least steps_per_epoch * epochs batches“, set the steps_per_epoch to steps_per_epoch = len(X_train)//batch_size validation_steps = len(X_test)//batch_size # if you have validation data You can see the maximum number of batches that model.fit() can take by the progress bar when the training interrupts: 5230/10000 [==============>……………] – ETA: 2:05:22 – loss: … Read more

keras BatchNormalization axis clarification

The confusion is due to the meaning of axis in np.mean versus in BatchNormalization. When we take the mean along an axis, we collapse that dimension and preserve all other dimensions. In your example data.mean(axis=0) collapses the 0-axis, which is the vertical dimension of data. When we compute a BatchNormalization along an axis, we preserve … Read more

Keras: model.predict for a single image

Since you trained your model on mini-batches, your input is a tensor of shape [batch_size, image_width, image_height, number_of_channels]. When predicting, you have to respect this shape even if you have only one image. Your input should be of shape: [1, image_width, image_height, number_of_channels]. You can do this in numpy easily. Let’s say you have a … Read more

How to understand the term `tensor` in TensorFlow?

TensorFlow doesn’t have first-class Tensor objects, meaning that there are no notion of Tensor in the underlying graph that’s executed by the runtime. Instead the graph consists of op nodes connected to each other, representing operations. An operation allocates memory for its outputs, which are available on endpoints :0, :1, etc, and you can think … Read more