How to save/load keras model with several branches - merge

I define a keras (2.0.6) model with two branches the merge these
left=Sequential()
...
right=Sequential()
...
model = Sequential()
model.add(Merge([left,right], mode='concat'))
model.save('mymodel.model')
Then later if I want to reuse my model after model = load('mymodel.model') I am getting
"ValueError: You are trying to load a weight file containing 5 layers into a model with 1 layers.".
So it seems the save command has only saved the 'model' part of my model, not the left and right branches. How can a save the entire model? Or will I need three model files, one for the left branch, one for the right and one for the merged model?
Seems there has been a discussion on this previously (https://github.com/fchollet/keras/issues/1349) but there was no solution, as far as I can see.
Does anyone know whether/how this has been solved?

Do not use the Sequential API for this, prefer the Functional API to build such a model with branches. Then you will only have a single model and it will be saved as such.

Related

Share data between two simulink models

Lets say I have following model
And I want the block in red to come from another model.I want them the two models to run independently and having them talk to each other.
I have read this https://www.mathworks.com/help/simulink/ug/share-data-with-other-matlab-system-blocks.html but I didn't help me
You're not really sharing data, you are asking about using one model inside another model. For this you want to use the Model Reference block.

Reference existing CF project models

We have multiple model projects using codefluent (M1 and M2).
Is it possible to have one model project (say M1) using type reference of another model project (M2) ?
I tried adding project reference or existing item in model but none of them worked.
The import feature doesn't seem to be the way to go either
Shall I consider having only one model project for my solution ?
Thanks for your answer,
I think you want to create a relationship between entities of both models.
If so, it's easier to have only one model. If you create multiple models because of their sizes, you may be interested in parts and surfaces to split it (blog post about surfaces).
If you want to have multiple models, I think it's possible to create relationships between entities (but I didn't test it). You need to create the entity in both model and play with the producer specific attribute enabled (cfps:enabled, cfom:enabled, etc.). Unless you really want to do complex things, I think you may stick to one model.

Can a project have two different EF data models that reference the same table?

I've system that has a primary data model to perform most of the work.
The model has quite a few tables and with performance in mind when I came to add an administrative feature to the application I decided to use a second separate data model.
All works well until my second data model needs to access a table that is also in the primary data model. Now, from digging around I can see this can cause problems.
The two possible workaround I've come up with are to either:
Put the data models in separate projects.
Use views / stored procedures for accessing the table in question when required.
Method 1 seems the simpliest but I'm concerned about whether there would be any performance loss. Method 2 seems a bit messy and takes the point out of using EF.
Before I plump for using method 1, is there an easier work around that I could use?
In the end I decided to put the two data models into separate projects and I've there hasn't been any slowdown that I've been able to notice (I've not done any benchmarking but it's passed the perception test).
In one of her online tutorials EF guru Julie Lerman says that you should put your data model in a separate project anyway, so I don't think this has been a bad workaround.
I am working with 2 models in the same project, because I connect to 2 different databases. I have put different namespaces using "Custom Tool Namespace" on *.tt files but it is not necessary. It generally works, but it cannot handle situation when the entity (table) with the same name is in both models. When you save one model the entity with the same name is deleted from the second model.

Difference between a Simulink library and a model reference

What are (If there are) the differences between a Simulink library and a model reference. There's advantadges in using either of them in different situations?
The main purpose of libraries and model reference are the same: facilitate the reuse of simulink models. When you work with libraries, simulink "imports" the content of the referenced models in to the main model. Sometimes, this leads to the developer dealing with gigantic models (more than 50k blocks), which can be time consuming. When you are designing a library, the lib file cannot be run. You have to "instantiate" it in the main model. On the other side, model reference deals with separated models. They are put together when you press the simulate button, but during the design time, you deal with completely separated models. With model reference, you can also select acceleration methods (it basically compiles the model) and this can't be done with libraries.
Adding some more to danielmsd's answer:
Configuration Management: Model references can be put easily into
version control and developers can work independently from each other. A library is one file, so the blocks
cannot be versioned individually and developers cannot work in parallel.
You can protect model references.
Code Generation: Incremental build is only possible with model referencing.
BUT:
Model referencing has quite a few limitations, so check them out carefully before picking this option. See Model Referencing Limitations.
From a system design perspective model references should be used for components of your system. That is the different parts your system is made from. Libraries should be used as utilities. That is reuable blocks that are used through out your design.
For example a robot control system includes components: navigation, control, path_plannen etc. These are components and should be implemented with model references. In that case they are developed as independent models and can be tested independently.
Inside the components you could need utility blocks such as low_pass_fileter, error_state_handler and check_input_range, they are libraries.
Advantages of mdl ref:
- Code generation: Model references allow partial builds when using the coder product. Assuming you have a really large model with 100k blocks and it takes 20 minutes to build, splitting it up in model references will reduce the build time since only the changed model will need to rebuild.
Model update: only changed model references are updated "CTRL+D" therefore this helps when having really large models.
Simulation: In simulations mdl refs are generated as dlls which makes your simulations much faster (the effect is much bigger than the difference between normal and accellerator mode)
Disadvantages pains:
- In general Mdl referencing is somehow a pain to use due to limitations
There is no possibility to pass a Simulink.parameter.object which has a tree structure. (When using type:BusObject only the value property has a structure, the other properties don't)
When a subsystem has a bus signal as input, a mdl ref needs a bus object to specify the input interface, and the library block doesen't. (Even if its quite ugly to use unspecified bus inputs in a lib block). (Note that busobject are always global in the base workspace... risk of naming collisions)

ADO.net Modeling Question

I have built my database design and diagram. Now i want to build a ADO.net model of that design. Now my question is that, should i build a model of the the whole design?(Since the design is not so big) or create several models for convenience? Which is better?
I have Student, Teacher, Course, .... tables
Should i make studentModel, TeacherModel.... or make only a ExamSystemModel of all the tables?
If it is a small model, you may get away with a single DataSet.
I have built models based on tasks and processes. I may build a DataSet with everything I need to register for a class, another one with everything needed to grade tests, etc.
I have built DataSets for single tables.
I have read data from DataReaders directly into entity objects.
Etc...
The architecture of the rest of the application will determine how you build your ADO.NET model. What are you trying to do with your system? How will it be used? Pick an architecture and build an appropriate model.