Questions tagged [reshape]

40 questions
5
votes
1 answer

Please explain input shape in Keras

My data consists of 2-dimensional arrays with shape (2,3). The whole dataset (emp) consists of 12 items (I know that it is too small of a number for an NN training, but it is just a test), so it has shape (12,2,3) truevals has shape (12,) When I try…
Sergey Kravchenko
  • 153
  • 1
  • 1
  • 4
5
votes
1 answer

Are view() in Pytorch and reshape() in Numpy similar?

Are view() in torch and reshape() in Numpy similar? view() is applied on torch tensors to change their shape and reshape() is a numpy function to change shape of ndarrays.
Kailash Ahirwar
  • 151
  • 1
  • 5
4
votes
1 answer

How to slice an input in keras?

I give to keras an input of shape input_shape=(500,). For some reasons, I would like to decompose the input vector into to vectors of respective shapes input_shape_1=(300,) and input_shape_2=(200,) I want to do this within the definition of the…
Contestosis
  • 171
  • 1
  • 6
3
votes
4 answers

rows to columns in data.table R (or Python)

This is something I can't achieve with the reshape2 library for R. I have the following data: zone code literal 1: A 14 bicl 2: B 14 bicl 3: B 24 calso 4: A 51 …
cpumar
  • 807
  • 1
  • 9
  • 14
2
votes
1 answer

ValueError: Shapes are incompatible when fitting using ImageDataGenerator

I got this error ValueError: Shapes (None, 1) and (None, 3) are incompatible when training my Sequential model. I could not figure out which shapes are actually incompatible. This is the first time I do image classification. Here are my codes: model…
GPraz
  • 123
  • 1
  • 1
  • 3
2
votes
1 answer

Keras input shape error

I am trying to load a Keras model and make predictions with it and run into a strange error. An minimal example is the following: from keras import models import numpy as np model =…
W. Verbeke
  • 141
  • 1
  • 5
2
votes
1 answer

Is the multilayer perceptron only able to accept 1d vector of input data? If yes, why is this so?

I am going through the tutorial at the link below which uses MNIST handwritten digit database. https://machinelearningmastery.com/handwritten-digit-recognition-using-convolutional-neural-networks-python-keras/ The 28x28 sized image data has to be…
user781486
  • 1,305
  • 2
  • 16
  • 18
1
vote
0 answers

How to correct format the dimension of the validation set - time series

I'm trying to understand how to add my validation data into my LSTM. At the moment I'm loading the train and the test set in the following way: First of all I load my time series from a directory, where they have a 2D shape (#values, #n_features =…
Fabio
  • 53
  • 9
1
vote
1 answer

Modifying U-Net implementation for smaller image size

I'm implementing the U-Net model per the published paper here. This is my model so far: def create_unet_model(image_size = IMAGE_SIZE): # Input layer is a 572,572 colour image input_layer = Input(shape=(image_size) + (3,)) """ Begin…
TomSelleck
  • 115
  • 5
1
vote
2 answers

Problem in input shape Keras-LSTM

I want to make a predictor using Keras LSTM model. I have a sequence of places visited. The task is to predict the last destination. I went through different examples but it seems I am not able to shape the input properly. I am stuck on how to…
bdur
  • 137
  • 3
1
vote
0 answers

pandas: reshaping the dataset, moving column name as rows

I currently have the following table: user_id --------- HR(segment_name) ------ observations. 123 1 0.9 234 . 0 . 0.78 567 0 0.99 789 …
Eli
  • 11
  • 1
1
vote
2 answers

Scalling and unscalling of data for SVR prediction

I'm trying to use SVR to predict a certain feature. I create the model with the following code: from sklearn.svm import SVR from sklearn.preprocessing import StandardScaler X = data # this is the outcome variable y = data.iloc[:, 10].values sc_X =…
MyName
  • 137
  • 3
  • 10
1
vote
1 answer

Keras loaded model output is different from the training model output

When I train my model it has a two-dimension output - it is (none, 1) - corresponding to the time series I'm trying to predict. But whenever I load the saved model in order to make predictions, it has a three-dimensional output - (none, 40, 1) -…
1
vote
2 answers

Data Reshaping for CNN using Keras

I'm a beginner in Keras. I've loaded MNIST dataset in Keras and checked it's dimension. The code is from keras.datasets import mnist # load data into train and test sets (X_train, y_train), (X_test, y_test) =…
Dr Nisha Arora
  • 123
  • 1
  • 8
1
vote
1 answer

how to create multiple plot from a panda Dataframe

I want to plot multiple plots. The data is stored in a pandas dataframe and each row should be a seperate plot. Each row has an ID (ZRD_ID) which doenst matter and a date (TAG) and 24 values to be plotted. import pandas as pd import numpy as np df…
CRoNiC
  • 147
  • 7
1
2 3