Error with nb 00_load_data

I’m just trying to run the NBs to get my head around things, and have hit an error pretty quickly.

As of about 20 minutes ago (~2019-04-22 1140 PDT) I’ve

  • Reinstalled the swift-tensorflow-DEVELOPMENT package
  • git pulled and reinstalled the jupyter kernel
  • git pulled the fastai_docs repo

Running the notebook 00_load_data is fine until cell 11 when I get this:

error: <Cell 12>:7:40: error: cannot convert value of type 'Int' to expected element type 'Int32'
    let shape: TensorShape = labels ? [batch] : (flat ? [batch, 784] : [batch, 28, 28])
                                       ^~~~~
                                       Int32( )

This is bringing back the utter bafflement of new error types in a new language :slight_smile: I’m not sure when it’s trying to convert an Int to an Int32. Is this PEBCAK or a bug?

Edit: Changing line 6 from:

    let batch = training ? 60000 : 10000

to

    let batch = training ? Int32(60000) : Int32(10000)

Has let me proceed. Perhaps this a “teachable moment” waiting to be explained in the lesson?

I think you don’t have properly registered your new build with jupyter. Just updated and 00 is running without any issue here.

Thanks! OK well that’s probably good. I used

python register.py --sys-prefix --swift-python-use-conda --use-conda-shared-libs --swift-toolchain ~/swift

In my swift-jupyter directory to register the kernel. Something changed because before that, I was getting a different error (complaining about the %install magic lines), and those went away after I did that. Is there anything else I should check?

Converting from Int32 to Int in general happened a few days ago: https://github.com/tensorflow/swift-apis/commit/23c16ae33a3826399b01caeb1b0b736531d00bde

Then, you’re just seeing side-effects from this. Use a nightly for now, or wait for a new official release and after that things should be fine!

Thanks Brett, is there a difference between a nightly and the swift-tensorflow-DEVELOPMENT-* bundle? Because I thought I was using that.

Oh from looking at the commit I’ll try installing a TensorFlow nightly as well, if that’s what you mean. I’ll give it a shot and report back. (Edit: no that’s the wrong tree to be barking up).

OK I’m happy to consider this a me problem. Hopefully v0.3 will be released any minute now and this’ll be fine. :slight_smile:

I think that installing the nightly build of S4TF should suffice. Perhaps jupyter is using a different version for some reason?

:man_facepalming: so it helps if you fg before you ctrl+c to restart jupyter…

…Nothing to see here, move along :face_with_head_bandage:

I think your version of swift is fine then? Registering the kernel here and using a nightly, runs beginning to end for me. For what it’s worth, wrapping everything in Int32() casts is the correct way of dealing with this error, you’re not doing anything wrong there.

That is good to know that the casting is right, thanks. But it was just user error, I hadn’t restarted jupyter after all. Cheers for the help!