Closed qichaozhao closed 7 years ago
Update, running it on the THEANO backend with an older version of Keras seems to bring much better results... I guess I will have to keep digging as to where the differences are coming from!
I seem to encounter the same problem, basically using the same code and fix a few minor place to be able to run on python 3, but the loss is not reducing and acc stays at 0.25
Saw discussion from another issue post, basically you seem to have to use RandomNormal as mentioned here https://keras.io/initializers/, instead of using the default glorot_uniform
Just to add it in all the convolution layers like this
initializer = RandomNormal(mean=0.0, stddev=0.05, seed=None)
...
conv = Convolution1D(nb_filter=nb_filter, filter_length=filter_kernels[0], kernel_initializer=initializer,
border_mode='valid', activation='relu',
input_shape=(maxlen, vocab_size))(inputs)
Initialization matters !!!
I finished running the neural network with ag_news set, using Keras version 2.1.5, Python 3.6.5, and I couldn't get Theano version, it seems it isn't installed. Doing it without any initializer in convolution layer, my network managed to get between 87%~92% of accuracy
Epoch: 8
Step: 100
Loss: 0.2301556259393692. Accuracy: 0.9221250146627427
Step: 200
Loss: 0.23537617575377226. Accuracy: 0.9201875126361847
Step: 300
Loss: 0.23534504453341165. Accuracy: 0.9205833458900452
Step: 400
Loss: 0.23604939280077816. Accuracy: 0.9202500122785569
Step: 500
Loss: 0.23330221936106682. Accuracy: 0.9211000119447708
Step: 600
Loss: 0.2331778311356902. Accuracy: 0.9213541778922081
Step: 700
Loss: 0.2310873696208. Accuracy: 0.9223928680590221
Step: 800
Loss: 0.23309540571644902. Accuracy: 0.9215625112503767
Step: 900
Loss: 0.23280121087200112. Accuracy: 0.9213472335868411
Step: 1000
Loss: 0.234288040317595. Accuracy: 0.9208625118732452
Step: 1100
Loss: 0.23586858349090273. Accuracy: 0.9205227390744469
Step: 1200
Loss: 0.2381015682592988. Accuracy: 0.9195833456019561
Step: 1300
Loss: 0.2377806937465301. Accuracy: 0.9194711661338806
Step: 1400
Loss: 0.2373836720788053. Accuracy: 0.9197500126702445
Step: 1500
Loss: 0.23760153172910214. Accuracy: 0.9196000128587087
Epoch 8. Loss: 0.3596184071741606. Accuracy: 0.8811842416462146
Epoch time: 0:07:20.014854. Total time: 1:08:38.125534
Epoch: 9
Step: 100
Loss: 0.21075385928153992. Accuracy: 0.9301250070333481
Step: 200
Loss: 0.21289151340723036. Accuracy: 0.9299375078082085
Step: 300
Loss: 0.21473157433172066. Accuracy: 0.9292916737000148
Step: 400
Loss: 0.21344165759161116. Accuracy: 0.9293750070035458
Step: 500
Loss: 0.21545475232601166. Accuracy: 0.9288500069379807
Step: 600
Loss: 0.21487088636805615. Accuracy: 0.9284791740775108
Step: 700
Loss: 0.21380332414593015. Accuracy: 0.9287678642783846
Step: 800
Loss: 0.21491042390465737. Accuracy: 0.9276875076442956
Step: 900
Loss: 0.21594439257350234. Accuracy: 0.9273194525639216
Step: 1000
Loss: 0.21687575853615998. Accuracy: 0.9271750084161758
Step: 1100
Loss: 0.21711503727869555. Accuracy: 0.9269545538858934
Step: 1200
Loss: 0.21854913759355743. Accuracy: 0.9265833417574565
Step: 1300
Loss: 0.21921507142484187. Accuracy: 0.9262211626768112
Step: 1400
Loss: 0.21991488710578. Accuracy: 0.9260446515253612
Step: 1500
Loss: 0.21934504335621993. Accuracy: 0.9262916754086812
Epoch 9. Loss: 0.3565275182849483. Accuracy: 0.8784210826221265
Epoch time: 0:07:19.129080. Total time: 1:16:13.310350
Hey there,
I've been looking at the Text Understanding from Scratch paper and am attempting to re-implement using Keras. I stumbled across your github during my research.
I cloned the repository and tried to run your code for the AG News dataset (downloaded from here: https://drive.google.com/drive/folders/0Bz8a_Dbh9Qhbfll6bVpmNUtUcFdjYmF2SEpmZUZUcVNiMUw1TWN6RDV3a0JHT3kxLVhVR2M)
It seems however the accuracy is plateaud at around 25%.
I am using a newer version of Keras (2.0.3) also with the Tensorflow backend, but given I didn't modify your code in any other way (apart from path names for the training / test data), I am unclear as to why it's doing this.
I will do some further testing by running with the THEANO backend and an older version of Keras to see if I can replicate your results.
However, in the meantime, I am just curious if this something you encountered at all when you were writing this code?
At least its consistent with my own implementation, which also is converging on 25% accuracy and staying there. :|