Hi, I received 100 to submit task “Transfer_learning_with_MobileNet_v1”
But i am stucking with code error at my own machine:
result =
32 for layer in model.layers:
—> 33 descriptors = [layer.class.name, layer.output_shape, layer.count_params()]
34 if (type(layer) == Conv2D):
35 descriptors.append(layer.padding)
AttributeError: ‘InputLayer’ object has no attribute ‘output_shape’
How could i fix this problem?
You mention that you are running this on your own machine. Did it work when you ran it on the course website? If so, then this may be caused by “versionitis”: you are probably running more recent versions of the various packages including TF. The assignments here were last reissued in April of 2021 so most of them use the versions that were current at that time. There is no guarantee that things still work with later versions of TF and the various other packages. You would think that things would evolve in backward compatible ways, but unfortunately it seems that is not universally true.
Here’s an example:
>>> import tensorflow as tf
>>> i = tf.keras.layers.InputLayer(shape=(10,))
>>> i.output.shape
(None, 10)
```python
1 Like
I changed layer.output_shape into layer.output.shape, then the following error comes out:
Yes, it runs well on coursera, i pass all test and received 100 score. But it is frustrating to run same code at my PyCharm IDE. You are right, it’s the problem of version. I am using the latest version. Those errors should be able to be fixed. I don’t know how.
Yes, there are ways to fix those things, but it will take work. Sorry, but if what you’re saying is that you expect us (the mentors) or DeepLearning.AI to solve this for you, that is not reasonable to expect. From DLAI’s point of view, they have given you a working environment. Their goal is education and they’ve done that. The intent was not that the notebooks become useful for building other projects (please see the Terms of Use, which say that the course material is for your personal use only). It is not reasonable to expect the mentors to be your IT support department for whatever you choose to do on your own personal computer or some other environment. There are just too many choices out there and we can’t know everything. Maybe you get lucky and some other person listening here has done a similar thing and can offer advice. See below for more on that.
You have two basic choices:
- Debug all the problems you encounter one by one. You’ll just have to do that yourself, although it should be possible to find help on StackExchange. For any problem like this, there are probably thousands of people who have already hit it.
- Learn to use “conda” or some equivalent tool to reproduce the old versions used on the course website.
Neither option is easy. Here’s a thread that will get you started on option 2) and here’s another one. There are more that you can find by searching the forums for “conda” or “anaconda”.
But maybe the better way to look at this is what I referred to above: the point of the course notebooks is education, not to be the basis of other projects. Your goal should be to take the ideas and then build your own solutions based on them. Learning to use your IT environment of choice successfully is a project in and of itself, which is beyond the scope of the courses here which just cover Deep Learning concepts.
One more thought: if you feel that you need to know more about TF, there are a whole set of specializations here which cover that, although I have not personally taken them.
1 Like