Network architecture understanding using keras code

My data is of 68871 x 43, where the features are in the column no. 1-43 and each label is represented as a 1x21 vector In my keras code: print trainX.shape -----> (41311, 10, 43) print...

Model summary in pytorch

How do I print the summary of a model in PyTorch like the model.summary() method does in Keras: Model...

How to use hyperopt for hyperparameter optimization of Keras deep learning network?

I want to build a non linear regression model using keras to predict a +ve continuous variable. For the below model how do I select the following hyperparameters? Number of Hidden layers and...

Google Colab is very slow compared to my PC

I've recently started to use Google Colab, and wanted to train my first Convolutional NN. I imported the images from my Google Drive thanks to the answer I got here. Then I pasted my code to...

Is there an optimizer in keras based on precision or recall instead of loss?

I am developping a segmentation neural network with only two classes, 0 and 1 (0 is the background and 1 the object that I want to find on the image). On each image, there are about 80% of 1 and...

How can I solve error "allocation exceeds 10 of system memory" on keras?

I made a CNN on Keras with Tensorflow backend, my training set has 144 examples, but each example has size of 3200*101. My CNN is very basic, just for learning, batch_size of 2 (I tried reducing...

ValueError while deploying tensorflow model to Amazon SageMaker

I want to deploy my trained tensorflow model to the amazon sagemaker, I am following the official guide here:...

TF Keras v 1.14+: subclass model or subclass layer for "module"

Tensorflow has some docs for subclassing (tf) Keras Model and Layer. However, it is unclear which to use for "modules" or "blocks" (e.g. several layers collectively). Since it is technically...

custom loss function in Keras combining multiple outputs

I did a lot of searching and am still unable to figure out writing a custom loss function with multiple outputs where they interact. I have a Neural Network defined as : def NeuralNetwork(): ...

Pytorch: can we use nn.Module layers directly in forward() function?

Generally, In the constructor, we declare all the layers we want to use. In the forward function, we define how the model is going to be run, from input to output. My question is what if calling...

Cannot clone object <tensorflow.python.keras.wrappers.scikit_learn.KerasClassifier object

This is with regards to TF 2.0. Please find below my code that performs GridSearch along with Cross Validation using sklearn.model_selection.GridSearchCV for the mnist dataset that works perfectly...

TimeDistributed of a KerasLayer in Tensorflow 2.0

I'm trying to build a CNN + RNN using a pre-trained model from tensorflow-hub: base_model = hub.KerasLayer('https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4', input_shape=(244, 244,...

Using tensorflow.keras model in pyspark UDF generates a pickle error

I would like to use a tensorflow.keras model in a pysark pandas_udf. However, I get a pickle error when the model is being serialized before sending it to the workers. I am not sure I am using the...

tensorflow:Can save best model only with val_acc available, skipping

I have an issue with tf.callbacks.ModelChekpoint. As you can see in my log file, the warning comes always before the last iteration where the val_acc is calculated. Therefore, Modelcheckpoint...

OSError: SavedModel file does not exist at: ../dnn/mpg_model.h5/{saved_model.pbtxt|saved_model.pb}

** code editor: vscode cmd: anaconda prompt I followed the tutorial but why this error? ** first error was ModuleNotFoundError: No module named 'tensorflow' but i make env and install it second...

Are we able to prune a pre-trained model? Example: MobileNetV2

I'm trying to prune a pre-trained model: MobileNetV2 and I got this error. Tried searching online and couldn't understand. I'm running on Google Colab. These are my imports. import tensorflow as...

How to use 'sample_weight' in keras

I want to implement Deep RL policy gradient. For that it is required to specify how much weight each sample in a batch should have in computing the total loss. My problem is I could not assign...

Modify code to be compatible on TensorFlow 2.3.0 (keras)

I got a tool that runs on TF1, but when I installed TF2 it stopped running because changes in the TF version. I need you help to update the code so that it will run on TF2. The code is is...

Saving normalization values in Keras model

I have a Keras model for which I would like to save the normalization values in the model object itself for easier portability. I'm using sklearn's StandardScaler() to normalize my data, so I...

Tensorflow for XOR is not predicting correctly after 500 epochs

I'm trying to implement a Neural Network to solve the XOR problem using TensorFlow. I chose sigmoid as activation function, shape (2, 2, 1) and optimizer=SGD(). I choose batch_size=1 because the...

TypeError: Could not build a TypeSpec with type KerasTensor

I am a newbie to deep learning so while I am trying to build a Masked R-CNN model for training my Custom Dataset I am getting an error which reads: TypeError: Could not build a TypeSpec for...

How to perform unsupervised learning on CNN

The model architecture This is the task that I am performing using this model Here is my model def create_convolution_layers(input_img): # 1st Convolutional Layer model =...

How to apply chain rule to multiple tf.GradientTape?

I'm studying pipeline model parallelism with TensorFlow 2 and MPI. But I can't figure out how to apply the chain rule when using multiple tf.GradientTape across multiple processes. Here is the...

module 'tensorflow.python.keras.backend' has no attribute 'slice'?

I am trying to implement https://github.com/ec-jrc/GHS-S2Net this project (in google colab). A week ago it was working by installing the requirements: !pip install tensorflow-gpu==2.0.0 !pip...

How to correctly save and load a model with custom CTC layer (Keras example)

I am following this tutorial on Keras , but I don't know how to correctly save this model with custom layer after the training and load it. This problem has been mentioned in here and here but...

How to clear Colab Tensorflow TPU memory

I am executing model for several folds. After each fold I want to clear the TPU memory so that I don't get OOM error. Full trace of the current error. ResourceExhaustedError ...

How to create a dynamic number of layers in Tensorflow?

In Keras, I would do the following to dynamically create a model's layers: for i in range(number_dense_layers): model.add(layers.Dense(units=units, input_dim=input_dim, ...

InternalError: Failed copying input tensor from device:CPU:0 to device:GPU:0 in order to run _EagerConst: Dst tensor is not initialized

[email protected]_machine:~/spatial/tuning_neighbors_7$ python3 *hyper*.py Traceback (most recent call last): File "tuner_hyperband.py", line 209, in <module> load_data_k( File...

Module 'keras.optimizers' has no attribute 'SGD'. Google Collab

I have notebook created on Google Collab. For work I need some functions of keras library. I imported them from tensorflow import keras from keras.models import Sequential from keras.layers...

Tensorflow setup in R | Error: Failed to load the native TensorFlow runtime

For the last 5 days, I am trying to make Keras/Tensorflow packages work in R. I am using RStudio for installation and have used conda, miniconda, virtualenv but it crashes each time in the end....