Giter Site home page Giter Site logo

taki0112 / senet-tensorflow Goto Github PK

View Code? Open in Web Editor NEW
757.0 31.0 271.0 464 KB

Simple Tensorflow implementation of "Squeeze and Excitation Networks" using Cifar10 (ResNeXt, Inception-v4, Inception-resnet-v2)

License: MIT License

Python 100.00%
senet inception-resnet inception densenet resnext tensorflow

senet-tensorflow's Introduction

SENet-Tensorflow

Simple Tensorflow implementation of Squeeze Excitation Networks using Cifar10

I implemented the following SENet

If you want to see the original author's code, please refer to this link

Requirements

  • Tensorflow 1.x
  • Python 3.x
  • tflearn (If you are easy to use global average pooling, you should install tflearn)

Issue

Image_size

  • In paper, experimented with ImageNet
  • However, due to image size issues in Inception network, so I used zero padding for the Cifar10
input_x = tf.pad(input_x, [[0, 0], [32, 32], [32, 32], [0, 0]]) # size 32x32 -> 96x96

NOT ENOUGH GPU Memory

  • If not enough GPU memory, Please edit the code
with tf.Session() as sess : NO
with tf.Session(config=tf.ConfigProto(allow_soft_placement=True)) as sess : OK

Idea

What is the "SE block" ?

senet

def Squeeze_excitation_layer(self, input_x, out_dim, ratio, layer_name):
    with tf.name_scope(layer_name) :
        squeeze = Global_Average_Pooling(input_x)

        excitation = Fully_connected(squeeze, units=out_dim / ratio, layer_name=layer_name+'_fully_connected1')
        excitation = Relu(excitation)
        excitation = Fully_connected(excitation, units=out_dim, layer_name=layer_name+'_fully_connected2')
        excitation = Sigmoid(excitation)

        excitation = tf.reshape(excitation, [-1,1,1,out_dim])

        scale = input_x * excitation

        return scale

How apply ? (Inception, Residual)

 

How "Reduction ratio" should I set?

reduction

  • original refers to ResNet-50

ImageNet Results

Benefits against Network Depth

depth

Incorporation with Modern Architecture

incorporation

Comparison with State-of-the-art

compare

Cifar10 Results

Will be soon

Related works

Reference

Author

Junho Kim

senet-tensorflow's People

Contributors

taki0112 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

senet-tensorflow's Issues

Result

Epoch:【100】 train accuracy:0.9999 test accuracy:0.9487

new dataset

@taki0112 I want to train new dataset with this model, must I resize the image to 32*32?

how to run the classification with unseem image (se_inception_resnet_v2 )

Hi, does anyone how to run the model with a unseen image, here is my code, hv no idea about the tensor name of output layer. Thanks.

import tensorflow as tf
import numpy as np
import cv2

sess=tf.Session()
saver = tf.train.import_meta_graph('model/Inception_resnet_v2.ckpt.meta')
saver.restore(sess, tf.train.latest_checkpoint("model/"))
graph = tf.get_default_graph()

x = tf.placeholder(tf.float32, shape=[None, 32, 32, 3])
src = cv2.imread("./plane.jpg")
src = 2*(src/255.0)-1.0
dst = cv2.resize(src, (32, 32), interpolation=cv2.INTER_CUBIC)
picture = dst.reshape(1, 32, 32, 3)

feed_dict ={x: picture}

op_to_restore = graph.get_tensor_by_name("dense_44/bias/Momentum:1")
print (sess.run(op_to_restore,feed_dict))

can just add squeeze_abode _layer in residual connection?

So if I just want to put a layer in the residuum connection, squeeze_abode _layer ok?
`
if residual :
if a.shape[-1] != b.shape[-1]:
a = squeeze_abode _layer (a,class_number,ratio,layer_number)
b = b+a
else:
b = b+a

`
I am not sure how to set ratio and layer_number parameters

The generated graph is degenerate

The flow of tensors is not visible in the graph. The name and variable scoping is not done properly due to which, the tensorboard graph visualizer ends up creating a flat and degenerate graph.

nan output

I use SE_Inception_v4.py to train the cifar10 data. The code can run normally, but the "train_loss", "train_acc", "test_loss" and "test_acc" are "nan". I try to output "batch_loss" from "_, batch_loss = sess.run([train, cost], feed_dict=train_feed_dict)", the result is "nan". Did anyone meet this problem?

Test acc on cifar10

Could you please upload the results on cifar10? Did you reproduce the results in the paper?

ensorflow.python.framework.errors_impl.InvalidArgumentError: Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero..'

I got this error when I retrain the network with my data set.

'tensorflow.python.framework.errors_impl.InvalidArgumentError: Reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero..'

I use a small data set of 525 and class_num is 6. How to modify the number of iterations and the 50,0000 value in the code? (In SE_Inception_v4.py)

I already put the new iteration value to a smaller value, say (iteration_n = len(train_x)/batch_size+ 1)
where batch_sze=128 and use this:

if pre_index + batch_size < batch_size*iteration_n: #in place of 50000
....
Any help is appreciated.

About the structure of SENet

Hi,
Before see your paper, I have saw the channel-wise in 'SCA-CNN', I think the two structures are vary similar, could you tell me the difference between them?
Thank you very much!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.