Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using NNI NAS interface with keras/tf.keras #1737

Closed
twelshed opened this issue Nov 14, 2019 · 2 comments
Closed

Using NNI NAS interface with keras/tf.keras #1737

twelshed opened this issue Nov 14, 2019 · 2 comments

Comments

@twelshed
Copy link

Hello,

I am attempting to use the nas interface with some tf.keras code to develop a U-net with learnable modules at each resolution. Are there any examples of using nni.mutable layers with tf.keras layers? All the examples I've found use tensorflow ops.

I get errors like this:

[11/14/2019, 10:46:01 PM] INFO (nni.nas_utils/MainThread) unet_nas/mutable_block_45_mutable_layer_0: layer: op.conv2d(size=1, fnum=fnum), optional inputs: []
[11/14/2019, 10:46:01 PM] ERROR (dstl-nas-keras/MainThread) int() argument must be a string, a bytes-like object or a number, not 'list'
Traceback (most recent call last):
File "dstl_keras_simple_nas.py", line 164, in
main()
File "dstl_keras_simple_nas.py", line 77, in main
spatial_dropout_rate=spatial_dropout, num_classes=8)
File "/tmp/twelsh/nni/annotation/tmpdlpnm2na/unet_nas.py", line 24, in create_unet
xin], {}, 0, 'classic_mode')
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/nni/smartparam.py", line 160, in mutable_layer
optional_input_size)
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/nni/nas_utils.py", line 47, in classic_mode
layer_out = funcs[chosen_layer]([fixed_inputs, real_chosen_inputs], **funcs_args[chosen_layer])
File "/tmp/twelsh/nni/annotation/tmpdlpnm2na/operators.py", line 7, in conv2d
activation='relu')(inputs)
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 817, in call
self._maybe_build(inputs)
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/keras/engine/base_layer.py", line 2141, in _maybe_build
self.build(input_shapes)
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/keras/layers/convolutional.py", line 147, in build
input_shape = tensor_shape.TensorShape(input_shape)
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py", line 776, in init
self._dims = [as_dimension(d) for d in dims_iter]
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py", line 776, in
self._dims = [as_dimension(d) for d in dims_iter]
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py", line 718, in as_dimension
return Dimension(value)
File "/home/twelsh/miniconda3/envs/nni/lib/python3.7/site-packages/tensorflow_core/python/framework/tensor_shape.py", line 193, in init
self._value = int(value)
TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

How to reproduce it:
Can provide code on request

nni Environment:

  • nni version:1.1
  • nni mode(local|pai|remote): local
  • OS: Ubuntu 18.04
  • python version: 3.7
  • is conda or virtualenv used?: conda
  • is running in docker?: no
@QuanluZhang
Copy link
Contributor

@twelshed sorry for the late response. We are refactoring NNI NAS interface, the refactored interface will be released in v1.2 on next Monday. You could refer to this tutorial (https://github.com/microsoft/nni/blob/v1.2/docs/en_US/NAS/Overview.md) for the usage of the new interface. The previous NAS interface becomes deprecated.

The new NAS interface is planned to support both pytorch and tensorflow2.0, in v1.2 we only release the pytorch version, the support of tensorflow2.0 will be released in v1.3

@scarlett2018
Copy link
Member

released in 1.6, please try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants