Skip to content
Advertisement

Tag: keras

Tensorflow/keras: “logits and labels must have the same first dimension” How to squeeze logits or expand labels?

I’m trying to make a simple CNN classifier model. For my training images (BATCH_SIZEx227x227x1) and labels (BATCH_SIZEx7) datasets, I’m using numpy ndarrays that are fed to the model in batches via ImageDataGenerator. The loss function I’m using is tf.nn.sparse_categorical_crossentropy. The problem arises when the model tries to train; the model (batch size here is 1 for my simplified experimentations) outputs

Tensorflow 2.0 – AttributeError: module ‘tensorflow’ has no attribute ‘Session’

When I am executing the command sess = tf.Session() in Tensorflow 2.0 environment, I am getting an error message as below: System Information: OS Platform and Distribution: Windows 10 Python Version: 3.7.1 Tensorflow Version: 2.0.0-alpha0 (installed with pip) Steps to reproduce: Installation: pip install –upgrade pip pip install tensorflow==2.0.0-alpha0 pip install keras pip install numpy==1.16.2 Execution: Execute command: import tensorflow

Gaierror while importing pretrained vgg model on kaggle

I am trying to import a pre-trained VGG model in keras on kaggle. I run through an gaierror which was unfamiliar. Downloading data from https://github.com/fchollet/deep-learning-models/releases/download/v0.1/vgg19_weights_tf_dim_ordering_tf_kernels_notop.h5 ————————————————————————— gaierror Traceback (most recent call last) /opt/conda/lib/python3.6/urllib/request.py in do_open(self, http_class, req, **http_conn_args) 1317 h.request(req.get_method(), req.selector, req.data, headers, -> 1318 encode_chunked=req.has_header(‘Transfer-encoding’)) 1319 except OSError as err: # timeout error /opt/conda/lib/python3.6/http/client.py in request(self, method, url, body,

InvalidArgumentError: cannot compute MatMul as input #0(zero-based) was expected to be a float tensor but is a double tensor [Op:MatMul]

Can somebody explain, how does TensorFlow’s eager mode work? I am trying to build a simple regression as follows: Gradient output: [None, None, None, None, None, None] The error is following: Edit I updated my code. Now, the problem comes in gradients calculation, it is returning zero. I have checked the loss value that is non-zero. Answer Part 1: The

How to fine-tune a functional model in Keras?

Taking a pre-trained model in Keras and replacing the top classification layer to retrain the network to a new task has several examples using a Sequential model in Keras. A sequential model has methods model.pop() and model.add() which make this fairly easy. However, how is this achieved when using a functional model? This framework does not have method model.add(). How

Input Shape for 1D CNN (Keras)

I’m building a CNN using Keras, with the following Conv1D as my first layer: I’m training with the function: In which train_df is a pandas dataframe of two columns where, for each row, label is an int (0 or 1) and payload is a ndarray of floats padded with zeros/truncated to a length of 1000. The total # of training

Keras CNN Error: expected Sequence to have 3 dimensions, but got array with shape (500, 400)

I’m getting this error: ValueError: Error when checking input: expected Sequence to have 3 dimensions, but got array with shape (500, 400) These are the below codes that I’m using. Output (here I’ve 500 rows in each): Code: Any insights? Answer Two things – Conv1D layer expects input to be in the shape (batch_size, x, filters), in your case (500,400,1).

Advertisement