Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Constructing a CNN model for a 2D input with Keras

General Tech Learning Aids/Tools

Max. 2000 characters
Replies

usr_profile.png

User

( 5 months ago )

 

I know that this kind of question has been already asked a ton of times before, but i haven't found a satisfactory answer or example that could aid me with the solution i'm looking for.

I'm pretty new to keras and data science in general, so excuse me if any of this sounds obvious or wrong.

I'm trying to create a CNN model that predicts a value from a 2D table (1M+, 16), the table has the following structure:

    Date  Name  [... 13 columns ... ]  Result
    1     A     ...                     0.5
    1     A     ...                     0.3
    1     A     ...                    -0.1
    ...
    1     B     ...                     0.4
    1     B     ...                    -0.8
    1     C     ...                     0.7
    ...
    2     A     ...                     0.15
    2     A     ...                     0.38
    ...

I have already tried several approaches, but the closest one was this:

def split_sequences(x_, y_ , n_steps):
  X, y = list(), list()
  for i in range(len(x_)):
      # find the end of this pattern
      end_ix = i + n_steps
      # check if we are beyond the dataset
      if end_ix > len(x_):
          break
      # gather input and output parts of the pattern
      seq_x, seq_y = x_[i:end_ix, :], y_[end_ix-1]
      X.append(seq_x)
      y.append(seq_y)
  return array(X), array(y)

n_steps = 5
# X and Y are the training sets, val_X and val_Y are the validation sets
X_, Y_ = split_sequences(X,Y,n_steps)
n_features = X_.shape[2]
val_X_, val_Y_ = split_sequences(val_X,val_Y,n_steps)
print(X_.shape)
print(Y_.shape)
print(val_X_.shape)
print(val_Y_.shape)


->(1804642, 5, 15)
->(1804642,)
->(601545, 5, 15)
->(601545,)


model = Sequential()
model.add(Conv1D(filters=64, kernel_size=2, activation

what's your interest