Code Monkey home page Code Monkey logo

Comments (1)

TitasDas avatar TitasDas commented on August 30, 2024

Thank you for this pointer , however I still am getting an error which is

ValueError: The name "dense_regress_178" is used 2 times in the model. All layer names should be unique.

I have named the layers in detect.py as follows

resnetlast = (model_classifier.layers[-1].output)
out_class = TimeDistributed(Dense(int(resnetlast.shape[2]), kernel_initializer='uniform'),name='time_distributed_2')(resnetlast)
out_class = Activation('relu')(out_class)
out_class = Dropout(.5)(out_class)
out_class = TimeDistributed(Dense(word.shape[0], activation='linear', kernel_initializer='uniform'),name='time_distributed_3')(out_class)
out_class = TimeDistributed(Dense(word.shape[0], activation='linear', kernel_initializer='uniform'),name='dense_class_{}'.format(nb_classes))(out_class)
out_class = MyLayer(output_dim=word_all.shape[1])(out_class) 

and this seems to be causing the problem

out_regr = TimeDistributed(Dense(4 * (nb_classes - 1), activation='linear', kernel_initializer='zero'),name='dense_regress_{}'.format(nb_classes))(resnetlast)      

Since this was a problem with the naming which is arbitrary I thought perhaps changing this to any other name like in the line below would solve this issue

out_regr = TimeDistributed(Dense(4 * (nb_classes - 1), activation='linear', kernel_initializer='zero'),name='dense_regressor_{}'.format(nb_classes))(resnetlast)      

it does get rid of the previous ValueError but causes an error when the model loads weights

model_classifier.load_weights(C.model_path, by_name=True)

ValueError: Layer #178 (named "time_distributed_2"), weight <tf.Variable 'time_distributed_2/kernel:0' shape=(708, 708) dtype=float32, numpy=
array([[ 0.03911747, -0.02416103, -0.04996177, ..., -0.00052779,
-0.04415029, 0.03913448],
[ 0.02350913, -0.04238098, 0.04727681, ..., 0.00107334,
0.03948401, 0.0225733 ],
[ 0.00324714, 0.0267023 , 0.03767557, ..., -0.03660261,
0.02911811, -0.04166988],
...,
[ 0.00710471, -0.02927768, 0.02644283, ..., 0.0140437 ,
0.02945073, -0.01651412],
[ 0.03027074, -0.03358974, 0.03127309, ..., -0.00256994,
-0.00981454, -0.00117335],
[ 0.00760389, 0.02819859, -0.02207704, ..., -0.01791253,
-0.04420076, -0.00320693]], dtype=float32)> has shape (708, 708), but the saved weight has shape (2048, 2048).

Any help to solve this is greatly appreciated. Also, posted the latter as a separate issue in case this isn't related to the naming mismatching.

from zsd_release.

Related Issues (11)

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.