Skip to content

Commit dca0bed

Browse files
moneyDboatmoneyDboat
moneyDboat
authored and
moneyDboat
committed
modify CNN model
1 parent c5c2f6a commit dca0bed

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ def ConvMF(res_dir, train_user, train_item, valid_user, test_user,
5353
# return the theta of CNN
5454
theta = cnn_module.get_projection_layer(CNN_X)
5555
np.random.seed(133)
56+
# dimension is the k
5657
U = np.random.uniform(size=(num_user, dimension))
5758
V = theta
59+
print("Jay::theta over")
5860

5961
endure_count = 5
6062
count = 0

run_test_ConvMF.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ python ./run.py \
33
-d ./data/preprocessed/ml-1m/0.2/ \
44
-a ./data/preprocessed/ml-1m/ \
55
-o ./test/ml-1m/result/1_100_200 \
6-
-e 200 \
7-
-p ./data/preprocessed/glove/glove.6B.200d.txt \
6+
-e 50 \
7+
-p ./data/preprocessed/glove/glove.6B.50d.txt \
88
-u 10 \
99
-v 100 \
1010
-g True

text_analysis/models.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ def __init__(self, output_dimesion, vocab_size, dropout_rate, emb_dim, max_len,
3838
# self.qual_model = Model()
3939
self.qual_conv_set = {}
4040

41-
filter_lengths = [3, 4, 5]
42-
4341
# my code
4442
'''Input'''
4543
input_data = Input(shape=(max_len, ), name='input', dtype='int32')
@@ -169,8 +167,8 @@ def train(self, X_train, V, item_weight, seed):
169167
item_weight = np.random.permutation(item_weight)
170168

171169
print("Train...CNN module")
172-
history = self.model.fit({'input': X_train, 'output': V},
173-
verbose=0, batch_size=self.batch_size, nb_epoch=self.nb_epoch, sample_weight={'output': item_weight})
170+
history = self.model.fit(X_train, V, verbose=0, batch_size=self.batch_size,
171+
nb_epoch=self.nb_epoch, sample_weight=item_weight)
174172

175173
# cnn_loss_his = history.history['loss']
176174
# cmp_cnn_loss = sorted(cnn_loss_his)[::-1]
@@ -180,6 +178,5 @@ def train(self, X_train, V, item_weight, seed):
180178

181179
def get_projection_layer(self, X_train):
182180
X_train = sequence.pad_sequences(X_train, maxlen=self.max_len)
183-
Y = self.model.predict(
184-
{'input': X_train}, batch_size=len(X_train))['output']
181+
Y = self.model.predict(X_train, batch_size=len(X_train))
185182
return Y

0 commit comments

Comments
 (0)