Giter Site home page Giter Site logo

Comments (7)

taehoonlee avatar taehoonlee commented on August 23, 2024

Thank you for trying TensorNets, @LynnHo. Can you share a TensorNets version and your snippets to reproduce the error? The different input shape is not related to the weight shape mismatching. Maybe, I guess that you use different classes. And the lines 321-324 are to handle the different classes as you expected.

from tensornets.

LynnHo avatar LynnHo commented on August 23, 2024

@taehoonlee I use a code like below,

import tensorflow as tf
import tensornets as nets

input_256 = tf.placeholder(dtype=tf.float32, shape=[None, 256, 256, 3])
network = nets.VGG16(input_256)
sess = tf.Session()

sess.run(network.pretrained())

and the error is,

ValueError: Dimension 0 in both shapes must be equal, but are 32768 and 25088. Shapes are [32768,4096] and [25088,4096]. for 'Assign_26' (op: 'Assign') with input shapes: [32768,4096], [25088,4096].

If the shape is [None, 224, 224, 3], the code works.

from tensornets.

taehoonlee avatar taehoonlee commented on August 23, 2024

@LynnHo, I see. I misunderstood the problem. The VGG16 and the VGG19 accept only a size of 224x224 because the fc6 layer produces a 4096-dimensional vector from a 25088(=77512)-dim vector. The error is from VGG's non-flexible architecture (accepting only fixed input sizes), not the line 320.

from tensornets.

LynnHo avatar LynnHo commented on August 23, 2024

@taehoonlee But if I just want to load the pretrained weights of Convs ignoring the FCs‘, line 320 is unsuitable. I modified the code at line 320-324 to blow, it works for me

ops = []
for w, v in zip(weights, values):
    if w.shape != v.shape:
        ops.append(w.initializer)
    else:
        ops.append(w.assign(v))

from tensornets.

taehoonlee avatar taehoonlee commented on August 23, 2024

@LynnHo, Thank you for the idea. But the proposed one will load all the weights except the middle layer fc6. I think it is error-prone. For the users who want to exploit all the weights, I think it is better to show the mismatch error rather than a silent error due to the random middle layer fc6.

from tensornets.

LynnHo avatar LynnHo commented on August 23, 2024

@taehoonlee You are right, the shape mismatch should be shown. Or an argument to control the ignoring of the shape mismatch would be better. Anyway, thanks a lot!

from tensornets.

taehoonlee avatar taehoonlee commented on August 23, 2024

@LynnHo, Yes I will considering the argument to control the shape mismatch. Thank you for the idea.

from tensornets.

Related Issues (20)

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.