Git Product home page Git Product logo

keras-text-transfer-learning's Issues

not able to predict with loaded model using universal embedding

Model architecture --->
adam=keras.optimizers.Adam(lr=0.0001)
early_stopping = keras.callbacks.ModelCheckpoint(filepath, monitor='val_acc', verbose=0, save_best_only=True, save_weights_only=False, mode='auto', period=10)
input_text = Input(shape=(1,), dtype="string")
embedding = Lambda(UniversalEmbedding, output_shape=(512, ))(input_text)
dense = Dense(1024)(embedding)
bnorm = BatchNormalization()(dense)
acti = Activation('relu')(bnorm)
pred = Dense(number_classes, activation='softmax')(acti)
model = Model(inputs=[input_text], outputs=pred)
model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=['accuracy',f1score,sensitivity,precision])

I loaded entire model as --->
with open('universal_model.json', 'r') as f:
model = model_from_json(f.read())
model.load_weights('./universal_model.h5')

Now fro prediction -->
predicts = model.predict(np.array(["hi"], dtype=object))
I get this error --->
FailedPreconditionError (see above for traceback): Attempting to use uninitialized value
module/Encoder_en/DNN/ResidualHidden_3/projection
[[{{node module_apply_default/Encoder_en/DNN/ResidualHidden_3/projection/read}} =
Identity[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"] .
(module/Encoder_en/DNN/ResidualHidden_3/projection)]]

TF version -- 1.11.0
Keras -- 2.2.4

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.