neural-network

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

TypeError: Sequential.__init__() takes from 1 to 3 positional arguments but 4 were given

TypeError: Sequential.__init__() takes from 1 to 3 positional arguments but 4 were given Question: Am not able to declare the model due to problems in input_shape input_shape = [x_train_scaled.shape[1]] input_shape Output – [6] model = tf.keras.Sequential( tf.keras.layers.Dense(units=64, input_shape=input_shape, activation=’relu’), tf.keras.layers.Dense(units=64, activation=’relu’), tf.keras.layers.Dense(units=1) ) model.summary() Error shown : TypeError: Sequential.init() takes from 1 to 3 positional …

Total answers: 1

Python code using multiprocessing works on Windows, but does not work on Ubuntu

Python code using multiprocessing works on Windows, but does not work on Ubuntu Question: I am trying to make the downloading of files from the server and their processing using a transformer model into separate processes. To practice working with a queue in multiprocessing, I wrote a small example that works fine on Windows, but …

Total answers: 1

Problems with numpy in Tensorflow

Problems with numpy in Tensorflow Question: from tensorflow import keras import matplotlib.pyplot as plt import numpy as np data = keras.datasets.boston_housing (x_train, x_test), (y_train, y_test) = data.load_data() model = keras.Sequential([ keras.layers.InputLayer(13), keras.layers.Dense(3, activation="relu"), keras.layers.Dense(1, activation="sigmoid") ]) model.compile(optimizer="adam", loss="sparse_categorical_crossentropy", metrics="accuracy") model.fit(x_train, y_train, epochs=10) predict = model.predict(x_test) for i in range(10): plt.grid(False) plt.imshow(x_test[i], cmap=plt.cm.binary) plt.suptitle("Actual: " + …

Total answers: 2

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

Converting column of object type to pytorch tensor

Converting column of object type to pytorch tensor Question: I am new to machine learning and python. I am working on data which has 2 columns of object type and a large number of columns of float type. For converting a float type columns to tensor, the below code works fine: cont_cols = [‘row_id’, ‘player1′,’player2′,’playervar_0′,’player_1’] …

Total answers: 2

pytorch I don't know how to define multiple models

pytorch I don't know how to define multiple models Question: I want to use two different models in pytorch. Therefore, I executed the following code, but I cannot successfully run the second model. How can I do this? class Model(nn.Module): def __init__(self): super(Model, self).__init__() self.linear1 = nn.Linear(2, 64) self.linear2 = nn.Linear(64, 3) def forward(self, x): …

Total answers: 1

How to use the dataset comes from pytorch random_split()?

How to use the dataset comes from pytorch random_split()? Question: I’m new to pyTorch and this is my first project. I need to split the dataset and feed the training dataset to model. The training dataset must be splitted in to features and labels (which I failed to do that). Here is what I have …

Total answers: 2

Simple Neural Network Using Pytorch

Simple Neural Network Using Pytorch Question: I want to build Simple Neural Network with pytorch. And I want to teach this network. the network has y = w(weight) * x + b(bias) with w = 3 and b = 0 so I have the data x = [1,2,3,4,5,6] y = [3,6,9,12,15,18] But I have some …

Total answers: 1