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

TFModel improvements #475

Merged
merged 12 commits into from Aug 20, 2020
Merged

TFModel improvements #475

merged 12 commits into from Aug 20, 2020

Conversation

SergeyTsimfer
Copy link
Member

@SergeyTsimfer SergeyTsimfer commented Jan 28, 2020

This PR proposes to:

  • Make ConvBlock able to chain multiple layers, just like Torch version can

  • Simplify logic of letter parsing, as well as adding capability of using R letter as separate Branch with complex parameters

  • Swap all arguments inside calls to conv_block to keyword ones

  • Add squeeze-and-excitation versions of ResNet

  • Re-check all the tests of model compilation

  • Add various attention modules: some of them are available through S (stands for self-attention) letter, some of them are mods of Combine

@codecov
Copy link

codecov bot commented Jan 28, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@ece231b). Click here to learn what that means.
The diff coverage is 25.73%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #475   +/-   ##
=========================================
  Coverage          ?   40.75%           
=========================================
  Files             ?      139           
  Lines             ?    14024           
  Branches          ?        0           
=========================================
  Hits              ?     5715           
  Misses            ?     8309           
  Partials          ?        0
Impacted Files Coverage Δ
batchflow/tests/tf_models_compile_test.py 62.5% <ø> (ø)
batchflow/models/tf/layers/pooling.py 33% <ø> (ø)
batchflow/models/tf/layers/conv.py 26.5% <ø> (ø)
batchflow/models/tf/layers/drop_block.py 14.03% <ø> (ø)
batchflow/models/tf/vgg.py 33.33% <0%> (ø)
batchflow/models/tf/refinenet.py 21.33% <0%> (ø)
batchflow/models/tf/inception_v4.py 19.27% <0%> (ø)
batchflow/models/tf/fcn.py 27.45% <0%> (ø)
batchflow/models/tf/layers/pyramid.py 14.13% <0%> (ø)
batchflow/models/tf/inception_v3.py 22.22% <0%> (ø)
... and 15 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ece231b...6240ba9. Read the comment docs.

batchflow/models/tf/base.py Outdated Show resolved Hide resolved
batchflow/models/tf/inception_resnet_v2.py Show resolved Hide resolved
batchflow/tests/tf_models_compile_test.py Outdated Show resolved Hide resolved
batchflow/models/tf/layers/core.py Outdated Show resolved Hide resolved
batchflow/models/tf/layers/conv.py Outdated Show resolved Hide resolved
get_indices = np.vectorize(lambda c, arr=classes: np.where(c == arr)[0])
value = get_indices(value)
classes = self.get_tensor_config(placeholder).get('classes')
if not isinstance(classes, int):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand it well but what if classes is int? Why can't be?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, TFModel is capable of working with custom class labels: [cats, dogs] for example. In this case, we need to manually transform such labels into int-classes, and this transform takes a lot of time. We don't need to do this in the case of integer classes.

batchflow/models/tf/layers/conv_block.py Show resolved Hide resolved
batch_size = get_batch_size(inputs, dynamic=True)
shape = get_shape(inputs)
ones = [1] * self.dim
if self.insert:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably insert can be renamed to something related to add_last, add_first or something?

batchflow/models/tf/layers/resize.py Outdated Show resolved Hide resolved
batchflow/models/tf/layers/resize.py Outdated Show resolved Hide resolved
@SergeyTsimfer
Copy link
Member Author

@SergeyTsimfer
Copy link
Member Author

@roman-kh roman-kh merged commit e8957da into master Aug 20, 2020
@roman-kh roman-kh deleted the tf_improvements branch August 20, 2020 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants