Category : tensorflow2.0

I created a tensorflow dataset. It is a mixed dataset and is in the format: <PrefetchDataset shapes: (((None, 224, 224, 3), (None, 12)), (None,)), types: ((tf.float32, tf.int32), tf.int32)> where (None, 224, 224, 3) refers to the batch of images, (None, 12) refers to corresponding metadata of the images(extracted from a csv file) and (None,) refers ..

Read more

I’m working on a project on Image Classification. Here I’ve 30 images and when I try to plot those images it gives me this error – InvalidArgumentError: slice index 5 of dimension 0 out of bounds. [Op:StridedSlice] name: strided_slice/ Below is my code: BATCH_SIZE = 5 IMAGE_SIZE = 256 CHANNELS=3 EPOCHS=10 train_ds = tf.keras.utils.image_dataset_from_directory( path_to_data, ..

Read more

I am trying to use: [SparseCategoricalCrossEntropy][https://www.tensorflow.org/api_docs/python/tf/keras/losses/SparseCategoricalCrossentropy] for multiclass classification This will give me the last dimension as the number of classes (N_CLASSES). But I want to retrive the actual class labels from the predictions. Basically if I have 5 classes (N_CLASSES=5), then I have 5 columns, each containing the probability of the class. But I ..

Read more

I have two arrays: inp_arr and indx_arr. The goal is to create sliding windows of the inp_arr from the indx_arr. In numpy, inp_arr[indx_arr] will create sliding windows of the inp_arr. Following is the MWE. import numpy as np inp_arr = np.random.rand(10, 3) # inp_arr array([[0.85257321, 0.07019212, 0.35636252], [0.32141462, 0.76053685, 0.88999183], [0.75308353, 0.79659116, 0.66134568], [0.32073745, 0.90427132, ..

Read more

I have two features: names and surnames. I zip them to use as multiple inputs for my model. Then I batch the datset. import tensorflow as tf names = tf.data.Dataset.from_tensor_slices(tf.ones(shape=(3,5,5))) surnames = tf.data.Dataset.from_tensor_slices(tf.zeros(shape=(3,5,5))) features = tf.data.Dataset.zip((names,surnames)).batch(3) So the shapes I am getting: <BatchDataset shapes: ((None, 5, 5), (None, 5, 5)), types: (tf.float32, tf.float32)> Then inside ..

Read more

**import tensorflow as tf import numpy as np xy = np.loadtxt(‘../data-01-test-score.csv’, delimiter=’,’, dtype=np.float32) x_data = xy[:, 0:-1] y_data = xy[:, [-1]] # Make sure the shape and data are OK print(x_data, "nx_data shape:", x_data.shape) print(y_data, "ny_data shape:", y_data.shape) # data output ”’ [[ 73. 80. 75.] [ 93. 88. 93.] … [ 76. 83. 71.] ..

Read more