Giter Site home page Giter Site logo

Comments (4)

jellchou avatar jellchou commented on September 1, 2024 3

@loretoparisi
Preds: 0 1 2 3 4 5
214536502 0.016009 0.016079 0.005016 0.005016 0.029079 0.022866
214536500 0.010071 0.010108 0.004129 0.004129 0.017137 0.013778
214536506 0.008890 0.008934 0.001951 0.001951 0.017141 0.013218
the column name is its id in batch, you need to rename this id to specific session_id.

from gru4rec.

loretoparisi avatar loretoparisi commented on September 1, 2024

[UPDATE]
With the code above I get an error

Epoch0	loss: 0.979422
Measuring Recall@19 and MRR@19
Recall@20: 0.007334788364521092
MRR@20: 0.0011454641877874099
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in __call__
    self.fn() if output_subset is None else\
IndexError: Index out of bounds.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_rsc15.py", line 54, in <module>
    preds = gru.predict_next_batch(iters, in_idx, predict_for_item_ids, batch_size)
  File "../../gru4rec.py", line 600, in predict_next_batch
    preds = np.asarray(self.predict(in_idxs)).T
  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 898, in __call__
    storage_map=getattr(self.fn, 'storage_map', None))
  File "/usr/local/lib/python3.5/dist-packages/theano/gof/link.py", line 325, in raise_with_op
    reraise(exc_type, exc_value, exc_trace)
  File "/usr/local/lib/python3.5/dist-packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/lib/python3.5/dist-packages/theano/compile/function_module.py", line 884, in __call__
    self.fn() if output_subset is None else\
IndexError: Index out of bounds.
Apply node that caused the error: GpuAdvancedSubtensor1(<GpuArrayType<None>(float64, (False, False))>, GpuContiguous.0)
Toposort index: 9
Inputs types: [GpuArrayType<None>(float64, (False, False)), GpuArrayType<None>(int64, (False,))]
Inputs shapes: [(37483, 3), (50,)]
Inputs strides: [(24, 8), (8,)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[InplaceGpuDimShuffle{1,0}(GpuAdvancedSubtensor1.0)]]

that is a IndexError: Index out of bounds..

from gru4rec.

loretoparisi avatar loretoparisi commented on September 1, 2024

I did a step forward in selecting session_ids, input_item_ids.

    batch_size=10
    session_ids = valid.SessionId.values[0:batch_size]
    input_item_ids = valid.ItemId.values[0:batch_size]
    predict_for_item_ids = None

    print('session_ids: {}'.format(session_ids))
    print('input_item_ids: {}'.format(input_item_ids))
    print('uniq_out: {}'.format(uniq_out))
    print('predict_for_item_ids: {}'.format(predict_for_item_ids))

    preds = gru.predict_next_batch(session_ids, input_item_ids, predict_for_item_ids, batch_size)
    preds.fillna(0, inplace=True)
    print('Preds: {}'.format(preds))

So far I get the dimension error for the predict_for_item_ids doing

out_idx = valid.ItemId.values[0:batch_size]
uniq_out = np.unique(np.array(out_idx, dtype=np.int32))
predict_for_item_ids = np.hstack([data, uniq_out[~np.in1d(uniq_out,data)]])    

so I'm just using predict_for_item_ids=None.

Given this I get

session_ids: [0 1 2 3 4 5 6 7 8 9]
input_item_ids: [214696432 214857030 214858854 214858854 214836819 214696434 214857570
 214858847 214859094 214690730]
uniq_out: [214690730 214696432 214696434 214836819 214857030 214857570 214858847
 214858854 214859094]
predict_for_item_ids: None

and a prediction ndarray of [37483 rows x 10 columns], that is like:

Preds:                   0         1         2         3         4         5  \
214536502  0.016009  0.016079  0.005016  0.005016  0.029079  0.022866   
214536500  0.010071  0.010108  0.004129  0.004129  0.017137  0.013778   
214536506  0.008890  0.008934  0.001951  0.001951  0.017141  0.013218 

Not sure about the dimension of this array actually.

from gru4rec.

loretoparisi avatar loretoparisi commented on September 1, 2024

@jellchou thank you!

from gru4rec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.