Skip to content

Commit

Permalink
Define input_shape via Input call in Sequential model in CNN
Browse files Browse the repository at this point in the history
  • Loading branch information
feranick committed Oct 8, 2024
1 parent 7458220 commit 0e53a7e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Installation
## Installation from available wheel package
If available from the main site, you can install SpectraKeras by running:

python3 -m pip install --upgrade spectrakeras-2024.10.07.3-py3-none-any.whl
python3 -m pip install --upgrade spectrakeras-2024.10.08.1-py3-none-any.whl

SpectraKeras_CNN and Spectrakeras_MLP are available directly from the command line.
NOTE: The Utilities in the `Utilities` folder are not included in the package, and can be run locally as needed.
Expand Down
8 changes: 5 additions & 3 deletions SpectraKeras-web/SpectraKeras_CNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''
**********************************************
* SpectraKeras_CNN Classifier and Regressor
* v2024.10.07.3
* v2024.10.08.1
* Uses: TensorFlow
* By: Nicola Ferralis <[email protected]>
**********************************************
Expand Down Expand Up @@ -338,11 +338,13 @@ def get_model():
amsgrad=False)

model = keras.models.Sequential()
model.add(keras.Input(shape=x_train[0].shape))

for i in range(len(dP.CL_filter)):
model.add(keras.layers.Conv2D(dP.CL_filter[i], (1, dP.CL_size[i]),
activation='relu',
input_shape=x_train[0].shape))
#input_shape=x_train[0].shape
))
try:
model.add(keras.layers.MaxPooling2D(pool_size=(1, dP.max_pooling[i])))
except:
Expand All @@ -366,7 +368,7 @@ def get_model():
for i in range(len(dP.HL)):
model.add(keras.layers.Dense(dP.HL[i],
activation = 'relu',
input_dim=A.shape[1],
#input_dim=A.shape[1],
kernel_regularizer=keras.regularizers.l2(dP.l2)))
model.add(keras.layers.Dropout(dP.dropFCL))

Expand Down
2 changes: 1 addition & 1 deletion SpectraKeras-web/libSpectraKeras.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'''
**********************************************
* libSpectraKeas - Library for SpectraKeras
* v2024.10.07.3
* v2024.10.08.1
* Uses: TensorFlow
* By: Nicola Ferralis <[email protected]>
**********************************************
Expand Down
6 changes: 4 additions & 2 deletions SpectraKeras/SpectraKeras_CNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,13 @@ def get_model():
amsgrad=False)

model = keras.models.Sequential()
model.add(keras.Input(shape=x_train[0].shape))

for i in range(len(dP.CL_filter)):
model.add(keras.layers.Conv2D(dP.CL_filter[i], (1, dP.CL_size[i]),
activation='relu',
input_shape=x_train[0].shape))
#input_shape=x_train[0].shape
))
try:
model.add(keras.layers.MaxPooling2D(pool_size=(1, dP.max_pooling[i])))
except:
Expand All @@ -366,7 +368,7 @@ def get_model():
for i in range(len(dP.HL)):
model.add(keras.layers.Dense(dP.HL[i],
activation = 'relu',
input_dim=A.shape[1],
#input_dim=A.shape[1],
kernel_regularizer=keras.regularizers.l2(dP.l2)))
model.add(keras.layers.Dropout(dP.dropFCL))

Expand Down

0 comments on commit 0e53a7e

Please sign in to comment.