Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the implementation compatible with recent TensorFlow and other updates #18

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
h5py==2.8.0
h5py==3.1.0
beautifulsoup4==4.6.3
lxml==4.6.3
numpy==1.15.4
tensorflow==2.4.0
numpy==1.19.2
tensorflow==2.5.2
nltk==3.4.5
Keras==2.2.4
Keras-Applications==1.0.6
Keras-Preprocessing==1.0.5
Keras-Preprocessing==1.1.2
folium==0.2.1
imgaug<0.2.7,>=0.2.5
18 changes: 10 additions & 8 deletions sentence_cnn_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,25 @@
import sys

import numpy as np
import keras

from sentence_types import load_encoded_data
from sentence_types import encode_data, import_embedding
from sentence_types import get_custom_test_comments

from keras.preprocessing import sequence
from keras.models import Sequential, model_from_json
from keras.layers import Dense, Dropout, Activation, Embedding
from keras.layers import Conv1D, GlobalMaxPooling1D
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
from tensorflow.keras.preprocessing import sequence
from tensorflow.keras.models import Sequential, model_from_json
from tensorflow.keras.layers import Dense, Dropout, Activation, Embedding
from tensorflow.keras.layers import Conv1D, GlobalMaxPooling1D

from keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.text import Tokenizer

# Use can load a different model if desired
model_name = "models/cnn"
embedding_name = "data/default"
load_model_flag = False
load_model_flag = True
arguments = sys.argv[1:len(sys.argv)]
if len(arguments) == 1:
model_name = arguments[0]
Expand Down Expand Up @@ -80,7 +82,7 @@

print('Constructing model!')

model = Sequential()
model = tf.keras.Sequential()

model.add(Embedding(max_words, embedding_dims,
input_length=maxlen))
Expand Down