Skip to content
This repository has been archived by the owner on Dec 5, 2018. It is now read-only.

Cannot cast array error when running start_mirt_pipeline.py #8

Open
brunojm opened this issue Dec 13, 2014 · 4 comments
Open

Cannot cast array error when running start_mirt_pipeline.py #8

brunojm opened this issue Dec 13, 2014 · 4 comments

Comments

@brunojm
Copy link

brunojm commented Dec 13, 2014

I'm getting:

$ python start_mirt_pipeline.py --generate --train -n 2 --visualize
Generating Responses
Generated responses for 500 students and 10 problems
Training MIRT models
Starting main.{'training_set_size': 1.0, 'regularization': 1e-05, 'emit_features': False, 'resume_from_file': '', 'max_pass_lbfgs': 5, 'sampling_num_steps': 200, 'workers': 1, 'num_epochs': 2, 'data_format': 'simple', 'sampling_epsilon': 0.2, 'num_replicas': 1, 'file': '/Users/bruno/Development/MachineLearning/guacamole/sample_data/models/train.responses', 'time': False, 'output': '/Users/bruno/Development/MachineLearning/guacamole/sample_data/models/1_no_time_2014-12-13 08:59:30.905104/', 'num_abilities': 1, 'max_time_taken': 1000.0}
loading dataTraining dataset, 436 students
10 exercises
epoch 0, Traceback (most recent call last):
File "start_mirt_pipeline.py", line 263, in
main()
File "start_mirt_pipeline.py", line 173, in main
run_with_arguments(arguments)
File "start_mirt_pipeline.py", line 237, in run_with_arguments
generate_model_with_parameters(arguments)
File "start_mirt_pipeline.py", line 205, in generate_model_with_parameters
mirt_train_EM.run_programmatically(mirt_train_params)
File "/Users/bruno/Development/MachineLearning/guacamole/mirt/mirt_train_EM.py", line 166, in run_programmatically
run(options)
File "/Users/bruno/Development/MachineLearning/guacamole/mirt/mirt_train_EM.py", line 249, in run
model.run_em_step(epoch)
File "/Users/bruno/Development/MachineLearning/guacamole/mirt/mirt_util.py", line 516, in run_em_step
results = self.get_sampling_results()
File "/Users/bruno/Development/MachineLearning/guacamole/mirt/mirt_util.py", line 496, in get_sampling_results
for ind in range(len(self.user_states))]
File "/Users/bruno/Development/MachineLearning/guacamole/mirt/mirt_util.py", line 260, in sample_abilities_diffusion_wrapper
np.random.seed([time.time() * 1e9])
File "mtrand.pyx", line 652, in mtrand.RandomState.seed (numpy/random/mtrand/mtrand.c:7775)
TypeError: Cannot cast array from dtype('float64') to dtype('int64') according to the rule 'safe'

I'm running in a MacOS 10.9.5, my pip freeze for the env for this project:

affinity==0.1.0
matplotlib==1.4.2
mock==1.0.1
nose==1.3.4
numpy==1.9.1
pyparsing==2.0.3
python-dateutil==2.3
pytz==2014.10
scipy==0.14.0
six==1.8.0
wsgiref==0.1.2

@himanshunimje
Copy link

@brunojm Did you get an answer to this? I am also stuck at the same error.
"TypeError: Cannot cast array from dtype('float64') to dtype('int64') according to the rule 'safe'"

@imoonkey
Copy link

Same problem here. wondering what to do.

Update: It is not working on my mac (OS X Yosemite 10.10.5) or my Ubuntu 14.04.1 LTS server.

@imoonkey
Copy link

This is because numpy.random.seed()'s input seed must be convertable to 32 bit unsigned integers.
Change the code in mirt/mirt_util.py starting from line 257 to the following code fixes this

    if len(id) > 0:
        np.random.seed([id[0], int(time.time() * 1e9) % 4294967296])
    else:
        np.random.seed([int(time.time() * 1e9) % 4294967296])

@ppkn
Copy link

ppkn commented Jan 29, 2016

This worked for me as well. I would create a pull request but I'm not sure if there is a less hacky way of fixing it.

Perevedko pushed a commit to Perevedko/guacamole that referenced this issue Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants