Skip to content

Small documentation enhancement request #18

Description

@walterreade

Hi there,
I really appreciate Hebel. It was a good first step for me to "take the plunge" into using GPU.

I struggled a bit after going through the example (MNIST) script. In particular, it wasn't clear how to have the model predict new data (i.e., data you don't have targets for).

The first (small) stumble was what to with the DataProvider. I just put in dummy zero targets. Perhaps targets could be an optional field somehow?

A more thorny issue was how to actually do the predictions. I couldn't for the life of me figure out how to feed the DataProvider data into the feed_forward without getting the error:

  File "/usr/local/lib/python2.7/dist-packages/hebel/models/neural_net.py", line 422, in feed_forward
    prediction=prediction))
  File "/usr/local/lib/python2.7/dist-packages/hebel/layers/input_dropout.py", line 96, in feed_forward
    return (input_data * (1 - self.dropout_probability),)
TypeError: unsupported operand type(s) for *: 'MiniBatchDataProvider' and 'float'

This was my original attempt:

# After loading in the data . . .
Xv = Xv.astype(np.float32)
yv = pd.get_dummies(yv).values.astype(np.float32)
valid_data = MiniBatchDataProvider(Xv, yv, batch_size=5000)

I finally resorted to useing a gpu array which worked:

from pycuda import gpuarray
valid_data = gpuarray.to_gpu(Xt)
y_pred = model.feed_forward(valid_data, return_cache=False, prediction=True).get()

The .get() at the end of the last statement was also something I had to figure out going through code.

Having an example in the documentation would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions