deep-learning

Keras Reshape Layer Error: Total Size of New Array Must Be Unchanged

Keras Reshape Layer Error: Total Size of New Array Must Be Unchanged Question: This is my model import torch import os import cv2 import numpy as np import tensorflow as tf from tensorflow.keras.preprocessing.image import ImageDataGenerator import mediapipe as mp from sklearn.metrics import multilabel_confusion_matrix, accuracy_score # Define the path to your training and testing data directories …

Total answers: 1

Can you reconstruct a Tensorflow neural network from the weights file (.h5) only?

Can you reconstruct a Tensorflow neural network from the weights file (.h5) only? Question: If you want to keep your Neural Network architecture secret and still want to use it in an application, would somebody to be able to reverse engineer the Neural Network from the weights file (.h5) only? The weights are an output …

Total answers: 1

How to replace this naive code with scaled_dot_product_attention() in Pytorch?

How to replace this naive code with scaled_dot_product_attention() in Pytorch? Question: Consider a code fragment from Crossformer: def forward(self, queries, keys, values): B, L, H, E = queries.shape _, S, _, D = values.shape scale = self.scale or 1./sqrt(E) scores = torch.einsum("blhe,bshe->bhls", queries, keys) A = self.dropout(torch.softmax(scale * scores, dim=-1)) V = torch.einsum("bhls,bshd->blhd", A, values) …

Total answers: 1

How to use pretrained encoder for customized Unet

How to use pretrained encoder for customized Unet Question: if you have a standard Unet encoder such as resnet50, then it’s easy to add pertaining to it. for example: ENCODER = ‘resnet50’ ENCODER_WEIGHTS = ‘imagenet’ CLASSES = class_names ACTIVATION = ‘sigmoid’ # could be None for logits or ‘softmax2d’ for multiclass segmentation # create segmentation …

Total answers: 1

np.concatenate dimension problem of 1 & 3 channel image input

np.concatenate dimension problem of 1 & 3 channel image input Question: I’m trying to train a future 7days broccoli Unet model I try to concatenate images, because my input have 8 channel(51channel 13channel[index 5]) appear this error message img_batch = np.concatenate(images, axis=3)________line172 mask_batch = np.concatenate(masks, axis=2)________line173 y_int = np.argmax(mask_batch, axis=2) y_binary = to_categorical(y_int) yield (img_batch, …

Total answers: 1

How can I reshape my image for a feedforward neural network

How can I reshape my image for a feedforward neural network Question: I am working on a Covid-19 image classification problem. I have Covid-19 and Normal CXRs images. Now I want to build a Feedforward Neural Network. This code i wrote keeps giving me an error and I am not sure what exactly I am …

Total answers: 1

I am trying to build a variational autoencoder. I am getting an error while running model.fit which I don't understand

I am trying to build a variational autoencoder. I am getting an error while running model.fit which I don't understand Question: Epoch 1/10 ————————————————————————— TypeError Traceback (most recent call last) <ipython-input-28-f82b6d9aa841> in <cell line: 2>() 1 # Train model —-> 2 model.fit(X_train, y_train, epochs=10, batch_size=16, validation_data=(X_val, y_val)) 1 frames /usr/local/lib/python3.9/dist-packages/keras/engine/training.py in tf__train_function(iterator) 13 try: 14 …

Total answers: 1

model.parameters() alternative for TransUNet from transunet python library

model.parameters() alternative for TransUNet from transunet python library Question: I am trying to implement TransUNet for breakhis dataset I was making the optimizer like this optimizer = torch.optim.Adam(model.parameters(), lr=1e-4) my model is from transunet import TransUNet model = TransUNet(image_size=224, pretrain=True) But the parameter() function does not work with TransUNet This is the library I am …

Total answers: 1

Pytorch deeplearning

Pytorch deeplearning Question: I am trying to train a model with the data of the size: torch.Size([280652, 87]) and the target: torch.Size([280652, 64]) with 80% in the training data and 20 in the test data. My code: #split the data in train and test X_train, X_test, y_train, y_test = train_test_split(data, target, test_size=0.2) # convert to …

Total answers: 1

Pytorch: Receiving same test evaluations each round

Pytorch: Receiving same test evaluations each round Question: I have a problem with my federated learning setup. I have some weights which I want to evaluate (test) each round using PyTorch. For now im interested in the loss and accuracy of the model. The weights are a list of numpy arrays. The model im using …

Total answers: 1