Understanding How to Shape Data for ConvLSTM2D in Keras The Next CEO of Stack Overflow2019 Community Moderator ElectionMy first machine learning experiment , model not converging , tips?Understand the shape of this Convolutional Neural NetworkMy Keras bidirectional LSTM model is giving terrible predictionsTraining Accuracy stuck in KerasRecurrent Neural Net (LSTM) batch size and inputUnderstanding Timestamps and Batchsize of Keras LSTM considering Hiddenstates and TBPTTKeras input shape errorUnderstanding LSTM input shape for kerasKeras/TF: Making sure image training data shape is accurate for Time Distributed CNN+LSTMLSTM - Forecasting usage (real world)

Why did early computer designers eschew integers?

Gauss' Posthumous Publications?

Which acid/base does a strong base/acid react when added to a buffer solution?

What is the difference between 서고 and 도서관?

Is it possible to make a 9x9 table fit within the default margins?

How badly should I try to prevent a user from XSSing themselves?

Car headlights in a world without electricity

What does this strange code stamp on my passport mean?

That's an odd coin - I wonder why

Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico

Can you teleport closer to a creature you are Frightened of?

How to find if SQL server backup is encrypted with TDE without restoring the backup

logical reads on global temp table, but not on session-level temp table

Why can't we say "I have been having a dog"?

Can I hook these wires up to find the connection to a dead outlet?

My boss doesn't want me to have a side project

What did the word "leisure" mean in late 18th Century usage?

Why was Sir Cadogan fired?

Is it "common practice in Fourier transform spectroscopy to multiply the measured interferogram by an apodizing function"? If so, why?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

What is the difference between 'contrib' and 'non-free' packages repositories?

pgfplots: How to draw a tangent graph below two others?

Do I need to write [sic] when including a quotation with a number less than 10 that isn't written out?

Strange use of "whether ... than ..." in official text



Understanding How to Shape Data for ConvLSTM2D in Keras



The Next CEO of Stack Overflow
2019 Community Moderator ElectionMy first machine learning experiment , model not converging , tips?Understand the shape of this Convolutional Neural NetworkMy Keras bidirectional LSTM model is giving terrible predictionsTraining Accuracy stuck in KerasRecurrent Neural Net (LSTM) batch size and inputUnderstanding Timestamps and Batchsize of Keras LSTM considering Hiddenstates and TBPTTKeras input shape errorUnderstanding LSTM input shape for kerasKeras/TF: Making sure image training data shape is accurate for Time Distributed CNN+LSTMLSTM - Forecasting usage (real world)










0












$begingroup$


Data: I have a spatio-temporal dataset which is approximately 5 years worth of crime data for New York City. This has been aggregated into a space-time grid so that the three dimensions of the matrix are longitude and latitude grid cells, and the time-frame. For this question let us say that there are 50x50 cells overlaid on the area and 100 time-frames for this question. So matrix dimensions are (50, 50, 100) and the cell value is the crime count.



Aim: I want to feed in data one time-frame at a time (as it becomes available) to predict the next timeframe.



Question: How should I shape the data for input as I am struggling on the understanding of how to make these forecasts and what data should be available/fed in?



Currently: Since the ConvLSTM2D Layer takes the following input (#Samples, Frame, Row, Col, Channel). I have reshaped as follows: (1, 100, 50, 50, 1) where I have a single video sample, which contains 100 frames, 50 rows and columns and a single channel. With x, y datasets as arr[:,:-1,:,:,:] and arr[:,1:,:,:,:] respectively.



Model I have created (might be wrong):



def createConvLSTMModel(dim0, dim1, dim2):

#Create the model
model = Sequential()

## Add layers to the model
#Add the first convolutional LSTM unit (with input)
model.add(ConvLSTM2D(filters=32,
kernel_size=(3, 3),
kernel_initializer='glorot_uniform',
strides=(1,1),
activation='relu',
batch_input_shape=(None, dim1, dim2, 1),
padding='same',
#stateful=True,
return_sequences=True))
#Perform batch normalisation
model.add(BatchNormalization())

#Add the second convolutional LSTM unit
model.add(ConvLSTM2D(filters=32,
kernel_size=(3, 3),
kernel_initializer='glorot_uniform',
strides=(1,1),
activation='relu',
padding='same',
#stateful=True,
return_sequences=True))
#Perform batch normalisation
model.add(BatchNormalization())


#Add the third convolutional LSTM unit
model.add(ConvLSTM2D(filters=64,
kernel_size=(3, 3),
kernel_initializer='glorot_uniform',
strides=(1,1),
activation='relu',
padding='same',
#stateful=True,
return_sequences=True))
#Perform batch normalisation
model.add(BatchNormalization())

#Add the fourth convolutional LSTM unit
model.add(ConvLSTM2D(filters=64,
kernel_size=(3, 3),
kernel_initializer='glorot_uniform',
strides=(1,1),
activation='relu',
padding='same',
#stateful=True,
return_sequences=True))
#Perform batch normalisation
model.add(BatchNormalization())

#Add a final 3D convolution Layer
model.add(Conv3D(filters=1, kernel_size=(3, 3, 3),
activation='sigmoid',
padding='same', data_format='channels_last'))

#Configure the model for training
model.compile(loss='binary_crossentropy', optimizer='adadelta')

#Return the model
return(model)
```









share|improve this question









$endgroup$
















    0












    $begingroup$


    Data: I have a spatio-temporal dataset which is approximately 5 years worth of crime data for New York City. This has been aggregated into a space-time grid so that the three dimensions of the matrix are longitude and latitude grid cells, and the time-frame. For this question let us say that there are 50x50 cells overlaid on the area and 100 time-frames for this question. So matrix dimensions are (50, 50, 100) and the cell value is the crime count.



    Aim: I want to feed in data one time-frame at a time (as it becomes available) to predict the next timeframe.



    Question: How should I shape the data for input as I am struggling on the understanding of how to make these forecasts and what data should be available/fed in?



    Currently: Since the ConvLSTM2D Layer takes the following input (#Samples, Frame, Row, Col, Channel). I have reshaped as follows: (1, 100, 50, 50, 1) where I have a single video sample, which contains 100 frames, 50 rows and columns and a single channel. With x, y datasets as arr[:,:-1,:,:,:] and arr[:,1:,:,:,:] respectively.



    Model I have created (might be wrong):



    def createConvLSTMModel(dim0, dim1, dim2):

    #Create the model
    model = Sequential()

    ## Add layers to the model
    #Add the first convolutional LSTM unit (with input)
    model.add(ConvLSTM2D(filters=32,
    kernel_size=(3, 3),
    kernel_initializer='glorot_uniform',
    strides=(1,1),
    activation='relu',
    batch_input_shape=(None, dim1, dim2, 1),
    padding='same',
    #stateful=True,
    return_sequences=True))
    #Perform batch normalisation
    model.add(BatchNormalization())

    #Add the second convolutional LSTM unit
    model.add(ConvLSTM2D(filters=32,
    kernel_size=(3, 3),
    kernel_initializer='glorot_uniform',
    strides=(1,1),
    activation='relu',
    padding='same',
    #stateful=True,
    return_sequences=True))
    #Perform batch normalisation
    model.add(BatchNormalization())


    #Add the third convolutional LSTM unit
    model.add(ConvLSTM2D(filters=64,
    kernel_size=(3, 3),
    kernel_initializer='glorot_uniform',
    strides=(1,1),
    activation='relu',
    padding='same',
    #stateful=True,
    return_sequences=True))
    #Perform batch normalisation
    model.add(BatchNormalization())

    #Add the fourth convolutional LSTM unit
    model.add(ConvLSTM2D(filters=64,
    kernel_size=(3, 3),
    kernel_initializer='glorot_uniform',
    strides=(1,1),
    activation='relu',
    padding='same',
    #stateful=True,
    return_sequences=True))
    #Perform batch normalisation
    model.add(BatchNormalization())

    #Add a final 3D convolution Layer
    model.add(Conv3D(filters=1, kernel_size=(3, 3, 3),
    activation='sigmoid',
    padding='same', data_format='channels_last'))

    #Configure the model for training
    model.compile(loss='binary_crossentropy', optimizer='adadelta')

    #Return the model
    return(model)
    ```









    share|improve this question









    $endgroup$














      0












      0








      0





      $begingroup$


      Data: I have a spatio-temporal dataset which is approximately 5 years worth of crime data for New York City. This has been aggregated into a space-time grid so that the three dimensions of the matrix are longitude and latitude grid cells, and the time-frame. For this question let us say that there are 50x50 cells overlaid on the area and 100 time-frames for this question. So matrix dimensions are (50, 50, 100) and the cell value is the crime count.



      Aim: I want to feed in data one time-frame at a time (as it becomes available) to predict the next timeframe.



      Question: How should I shape the data for input as I am struggling on the understanding of how to make these forecasts and what data should be available/fed in?



      Currently: Since the ConvLSTM2D Layer takes the following input (#Samples, Frame, Row, Col, Channel). I have reshaped as follows: (1, 100, 50, 50, 1) where I have a single video sample, which contains 100 frames, 50 rows and columns and a single channel. With x, y datasets as arr[:,:-1,:,:,:] and arr[:,1:,:,:,:] respectively.



      Model I have created (might be wrong):



      def createConvLSTMModel(dim0, dim1, dim2):

      #Create the model
      model = Sequential()

      ## Add layers to the model
      #Add the first convolutional LSTM unit (with input)
      model.add(ConvLSTM2D(filters=32,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      batch_input_shape=(None, dim1, dim2, 1),
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())

      #Add the second convolutional LSTM unit
      model.add(ConvLSTM2D(filters=32,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())


      #Add the third convolutional LSTM unit
      model.add(ConvLSTM2D(filters=64,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())

      #Add the fourth convolutional LSTM unit
      model.add(ConvLSTM2D(filters=64,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())

      #Add a final 3D convolution Layer
      model.add(Conv3D(filters=1, kernel_size=(3, 3, 3),
      activation='sigmoid',
      padding='same', data_format='channels_last'))

      #Configure the model for training
      model.compile(loss='binary_crossentropy', optimizer='adadelta')

      #Return the model
      return(model)
      ```









      share|improve this question









      $endgroup$




      Data: I have a spatio-temporal dataset which is approximately 5 years worth of crime data for New York City. This has been aggregated into a space-time grid so that the three dimensions of the matrix are longitude and latitude grid cells, and the time-frame. For this question let us say that there are 50x50 cells overlaid on the area and 100 time-frames for this question. So matrix dimensions are (50, 50, 100) and the cell value is the crime count.



      Aim: I want to feed in data one time-frame at a time (as it becomes available) to predict the next timeframe.



      Question: How should I shape the data for input as I am struggling on the understanding of how to make these forecasts and what data should be available/fed in?



      Currently: Since the ConvLSTM2D Layer takes the following input (#Samples, Frame, Row, Col, Channel). I have reshaped as follows: (1, 100, 50, 50, 1) where I have a single video sample, which contains 100 frames, 50 rows and columns and a single channel. With x, y datasets as arr[:,:-1,:,:,:] and arr[:,1:,:,:,:] respectively.



      Model I have created (might be wrong):



      def createConvLSTMModel(dim0, dim1, dim2):

      #Create the model
      model = Sequential()

      ## Add layers to the model
      #Add the first convolutional LSTM unit (with input)
      model.add(ConvLSTM2D(filters=32,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      batch_input_shape=(None, dim1, dim2, 1),
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())

      #Add the second convolutional LSTM unit
      model.add(ConvLSTM2D(filters=32,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())


      #Add the third convolutional LSTM unit
      model.add(ConvLSTM2D(filters=64,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())

      #Add the fourth convolutional LSTM unit
      model.add(ConvLSTM2D(filters=64,
      kernel_size=(3, 3),
      kernel_initializer='glorot_uniform',
      strides=(1,1),
      activation='relu',
      padding='same',
      #stateful=True,
      return_sequences=True))
      #Perform batch normalisation
      model.add(BatchNormalization())

      #Add a final 3D convolution Layer
      model.add(Conv3D(filters=1, kernel_size=(3, 3, 3),
      activation='sigmoid',
      padding='same', data_format='channels_last'))

      #Configure the model for training
      model.compile(loss='binary_crossentropy', optimizer='adadelta')

      #Return the model
      return(model)
      ```






      keras tensorflow lstm convnet reshape






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 25 at 8:28









      Daniel JDaniel J

      11




      11




















          0






          active

          oldest

          votes












          Your Answer





          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "557"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47926%2funderstanding-how-to-shape-data-for-convlstm2d-in-keras%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Data Science Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          Use MathJax to format equations. MathJax reference.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdatascience.stackexchange.com%2fquestions%2f47926%2funderstanding-how-to-shape-data-for-convlstm2d-in-keras%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Adding axes to figuresAdding axes labels to LaTeX figuresLaTeX equivalent of ConTeXt buffersRotate a node but not its content: the case of the ellipse decorationHow to define the default vertical distance between nodes?TikZ scaling graphic and adjust node position and keep font sizeNumerical conditional within tikz keys?adding axes to shapesAlign axes across subfiguresAdding figures with a certain orderLine up nested tikz enviroments or how to get rid of themAdding axes labels to LaTeX figures

          Luettelo Yhdysvaltain laivaston lentotukialuksista Lähteet | Navigointivalikko

          Gary (muusikko) Sisällysluettelo Historia | Rockin' High | Lähteet | Aiheesta muualla | NavigointivalikkoInfobox OKTuomas "Gary" Keskinen Ancaran kitaristiksiProjekti Rockin' High