GithubHelp home page GithubHelp logo

Comments (4)

pplonski avatar pplonski commented on July 22, 2024

Sorry, it is hard to say ... what Keras verison are you using? Do you use theano as backend?

from keras2cpp.

xdtl avatar xdtl commented on July 22, 2024

Thanks for your reply! I don't know which Keras version it is, because I used Amazon AWS to run my code instead of building my own machine. It did show it is using theano backend.

At first, I got 'arch["config"]' like this:
{u'layers': [{u'class_name': u'InputLayer', u'inbound_nodes': [], u'config': {u'batch_input_shape': [None, 1, 160, 128], u'sparse': False, u'input_dtype': u'float32', u'name': u'input_1'}, u'name': u'input_1'}, {u'class_name': u'Convolution2D', u'inbound_nodes': [[[u'input_1', 0, 0]]], u'config': {u'W_constraint': None, u'b_constraint': None, u'name': u'convolution2d_1', u'activity_regularizer': None, u'trainable': True, u'dim_ordering': u'th', u'nb_col': 3, u'subsample': [1, 1], u'init': u'glorot_uniform', u'bias': True, u'nb_filter': 32, u'b_regularizer': None, u'W_regularizer': None, u'nb_row': 3, u'activation': u'relu', u'border_mode': u'same'}, u'name': u'convolution2d_1'}, {u'class_name': u'Convolution2D', u'inbound_nodes': [[[u'convolution2d_1', 0, 0]]], ...

There are a lot of 'u'. I searched online and found it was Unicode object. I followed the suggestions to replace your original code "arch = json.loads(arch)" with "arch = yaml.safe_load(arch)" or "arch = simplejson.loads(arch)". Those 'u' disappeared, but the error is still there...

from keras2cpp.

pplonski avatar pplonski commented on July 22, 2024

Try to change line 30:

for ind, l in enumerate(arch["config"]):

to

for ind, l in enumerate(arch["layers"]):

This should help, but for sure it will require more custom changes and I can help with this - sorry! You should change this code by yourself for your needs.

from keras2cpp.

xdtl avatar xdtl commented on July 22, 2024

Thanks very much! This is very helpful. It seems the layout of arch varies from case to case. I tried:
for ind, l in enumerate(arch["config"]["layers"]):
and got dumped.nnet. But test_run_cnn.cc generated another error:
"Layer is empty, maybe it is not defined? Cannot define network."
The problem lies in keras_model.cc, keras::KerasModel::load_weights:
layer_type =="InputLayer",
which doesn't meet any of those if...else... conditions.

I fully understand I am responsible to change it for my own needs. But any directions or suggestions are highly appreciated.

from keras2cpp.

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.