SenticNet / personality-detection

Implementation of a hierarchical CNN based model to detect Big Five personality traits
http://sentic.net/deep-learning-based-personality-detection.pdf
MIT License
475 stars 167 forks source link

Type Issues? #6

Closed padenr closed 6 years ago

padenr commented 6 years ago

I seem to be running into some issues with the TensorTypes. I'm using the memory optimized preprocess file that was posted in another issue thread. But I don't think that's the issue here. Any help would be greatly appreciated.

python conv_net_train.py -static -word2vec 2 loading data... data loaded! model architecture: CNN-static using: word2vec vectors [('image shape', 153, 300), ('filter shape', [(200, 1, 1, 300), (200, 1, 2, 300), (200, 1, 3, 300)]), ('hidden_units', [200, 200, 2]), ('dropout', [0.5, 0.5, 0.5]), ('batch_size', 50), ('non_static', False), ('learn_decay', 0.95), ('conv_non_line ar', 'relu'), ('non_static', False), ('sqr_norm_lim', 9), ('shuffle_batch', True)] Traceback (most recent call last): File "conv_net_train.py", line 476, in activations=[Sigmoid]) File "conv_net_train.py", line 179, in train_conv_net allow_input_downcast = True) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/function.py", line 326, in function output_keys=output_keys) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 449, in pfunc no_default_updates=no_default_updates) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 219, in rebuild_collect_shared cloned_v = clone_v_get_shared_updates(v, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 93, in clone_v_get_shared_updates clone_v_get_shared_updates(i, copy_inputs_over) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/compile/pfunc.py", line 96, in clone_v_get_shared_updates [clone_d[i] for i in owner.inputs], strict=rebuild_strict) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/gof/graph.py", line 238, in clone_with_new_inputs new_inputs[i] = curr.type.filter_variable(new) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/tensor/type.py", line 235, in filter_variable self=self)) TypeError: Cannot convert Type TensorType(float64, matrix) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(float32, matrix). You can try to manually convert Subtensor{int64:int64:}.0 into a TensorType(float32, matrix).

naikzinal commented 6 years ago

dear @padenr you need to update yr theanorc file : [global] floatX=float32 it may solve the error.

padenr commented 6 years ago

I actually did that before and I got this other error. So I wasn't sure whether I was supposed to keep that line in or not. Based on your advice I assume it should be. But what about this error? This error only engages when I add the above to my .theanorc.

loading data... data loaded! model architecture: CNN-static using: word2vec vectors [('image shape', 153, 300), ('filter shape', [(200, 1, 1, 300), (200, 1, 2, 300), (200, 1, 3, 300)]), ('hidden_units', [200, 200, 2]), ('dropout', [0.5, 0.5, 0.5]), ('batch_size', 50), ('non_static', False), ('learn_decay', 0.95), ('conv_non_linear', 'relu'), ('non_static', False), ('sqr_norm_lim', 9), ('shuffle_batch', True)] Traceback (most recent call last): File "conv_net_train.py", line 476, in activations=[Sigmoid]) File "conv_net_train.py", line 123, in train_conv_net convfeats, = theano.scan(fn= convolve_user_statuses, sequences= layer0_input) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/scan_module/scan.py", line 773, in scan condition, outputs, updates = scan_utils.get_updates_and_outputs(fn(args)) File "conv_net_train.py", line 115, in convolve_user_statuses layer1_inputs.append(conv_layer.set_input(input=relv_input).flatten(2)) File "conv_net_classes.py", line 393, in set_input conv_out = conv.conv2d(input=input, filters=self.W,filter_shape=self.filter_shape, image_shape=self.image_shape) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/tensor/nnet/conv.py", line 153, in conv2d return op(input, filters) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/gof/op.py", line 615, in call node = self.make_node(inputs, **kwargs) File "/home/rumsey_pr/anaconda2/lib/python2.7/site-packages/theano/tensor/nnet/conv.py", line 655, in make_node "inputs(%s), kerns(%s)" % (_inputs.dtype, _kerns.dtype)) NotImplementedError: The image and the kernel must have the same type.inputs(float64), kerns(float32)

naikzinal commented 6 years ago

dear @padenr , i also have the same issue. i also got the same error if u able to solve please give me solution too.

padenr commented 6 years ago

I managed to get rid of this error by going into conv_net_classes.py and changing line 393 (give or take a line in mine) from

    conv_out = conv.conv2d(input=input, filters=self.W,filter_shape=self.filter_shape, image_shape=self.image_shape)

to

    conv_out = conv.conv2d(input=T.cast(input, theano.config.floatX), filters=self.W,filter_shape=self.filter_shape, image_shape=self.image_shape)

where floatX = float32 in my theanorc file.

Doing this gets it to the actual training phase. BUT the training will never finish. I watched it run for a few hours hoping it would work and it never did. Please tell me if you can get it to work. And if you do what hardware you are running your CNN on.

naikzinal commented 6 years ago

dear @padenr thank you so much for given the soluation. but while running the code i found the memory issue.my training phase was not start.

loading data... data loaded! model architecture: CNN-static using: word2vec vectors [('image shape', 153, 300), ('filter shape', [(200, 1, 1, 300), (200, 1, 2, 300), (200, 1, 3, 300)]), ('hidden_units', [200, 200, 2]), ('dropout', [0.5, 0.5, 0.5]), ('batch_size', 50), ('non_static', False), ('learn_decay', 0.95), ('conv_non_linear', 'relu'), ('non_static', False), ('sqr_norm_lim', 9), ('shuffle_batch', True)] ... training Traceback (most recent call last): File "conv_net_train.py", line 477, in activations=[Sigmoid]) File "conv_net_train.py", line 221, in train_conv_net cost_epoch = train_model(minibatch_index) File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 606, in call storage_map=self.fn.storage_map) File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 595, in call outputs = self.fn() MemoryError: Apply node that caused the error: AdvancedSubtensor1(Words, Elemwise{Cast{int32}}.0) Inputs types: [TensorType(float64, matrix), TensorType(int32, vector)] Inputs shapes: [(30392, 300), (2386800,)] Inputs strides: [(2400, 8), (4,)] Inputs values: ['not shown', 'not shown']

HINT: Re-running with most Theano optimization disabled could give you a back-trace of when this node was created. This can be done with by setting the Theano flag 'optimizer=fast_compile'. If that does not work, Theano optimizations can be disabled with 'optimizer=None'. HINT: Use the Theano flag 'exception_verbosity=high' for a debugprint and storage map footprint of this apply node.

padenr commented 6 years ago

Hmm. I didn't get that one so I don't really know honestly. I imagine since we've gotten most of the same errors that I should get this one too. But I don't know.

naikzinal commented 6 years ago

heloo @padenr can u tell me how u install the THEANO in anaconda environment ? i think the error is occur bcz of incomplete installation of theano packege.

padenr commented 6 years ago

You're computer doesn't have enough RAM to run the program.