I have a 3D NumPy array of size (9,9,200) and a 2D array of size (200,200). I want to take each channel of shape (9,9,1) and generate an array (9,9,200), every channel multiplied 200 times by 1 scalar in a single row, and average it such that the resultant array is (9,9,1). Basically, if there ..
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, ..
I’m currently running Colab in an attempt to classify images using a CNN. I’m trying to find why this issue is being caused but I’m struggling to diagnose it & ultimate fix it. I’m splitting my datasets as follows: all_images,type1,type2=,, # Arrays to store data for file in files: image=cv2.imread(folder + file, 0) all_images.append(image) split_var=file.split(‘_’) ..
I encountered this error while training my neural network in pytorch. I am trying to pass images of size 48*48, in B&W which have only 3 features. As you can see here: torch.Size([3, 48, 48]) 0 I am not sure how relevant this is, but I have a 1000 different images for training, as well ..
I have a time series t composed of 30 features, with a shape of (5400, 30). To plot it and identify the anomalies I had to reshape it in the following way: t = t[:,0].reshape(-1) Now, it became a single tensor of shape (5400,) where I had the possibility to perform my analysis and create ..
I am trying to define a custom rmse loss function for Keras. I wrote the function below to penalize the loss when the value of the data is less than 0.15 and otherwise. import keras.backend as K def custom_rmse(y_true, y_pred): loss = K.square(y_pred – y_true) for i in range(len(y_true)): for j in range(y_true.shape): tmp = ..
I’m writing a code for reinforcement learning using Python 3 and Pytorch 1.9.1. I post a question because I don’t understand the error line. The error occurs on the line of the loss.mean().backward(). It is said that the dtype should have a float, but the double came in, but no matter how much the dtype ..
I am trying to predict the fluid flow (CFD) in 3d grid. How do I resolve the shape issue for 3D CNN using TensorFlow Keras? My data is in array format, converted from 3D voxels of size 26x26x25 (each position has binary intersection values). The sample dataset I using : xi yi zi Intersection Pressure ..
I have a PyTorch model and i am doing prediction on it. After doing prediction i am getting the output as tensor([[-3.4333]], grad_fn=<AddmmBackward>) But i need it as normal integer -3.4333. How can i do it. Source: Python..
I am computing the gradient on a minibatch of 256 elements in the following way: # input object input_tensor = tf.convert_to_tensor(np.array(256,w,h)) # target object target_tensor = tf.convert_to_tensor(np.array(256,w,h)) # watch the tensor to compute a gradient on it tape.watch(input_tensor) # perform feed forward pass output= model(input_tensor) # compute the loss with respect to the target representation ..