I came across a problem when I read a book. In the book, it describes a method to create a curve in Modelica. For example:
model Spring
mechanism.translation...
...
Curve Fscurve(
x(quantity="Mechanics.Translation.Displace",
displayUnit="mm"={0,0.06,1},
y[1]mono=0,
interpol=3,extra=true,mirror=true,cycle=false,
quantity="Mechanics.Translation.Force"={0,350,1000}
)
...
end Spring;
Does anyone know the function of Curve Fscurve? Where does Curve Fscurve come from?
Curve is not a function. It is a class that is looked up and it is instantiated with the name FScurve.
There is no top-level Curve available as default in Modelica. So I would say the example in your book either defined Curve somewhere or it simply assumes that a class Curve exists.
Due to the way Name lookup is performed in Modelica, Curve could be in the same package as the model Spring or anywhere in the path up to the top level.
Example 1: Two curves, one local
- Curve
- Mechanics
|- Spring
|- Curve // Fscurve refers to this class
Example 2: One curve at top-level
- Curve // Fscurve refers to this class
- Mechanics
|- Spring
|- Foo
Example 3: Two curves, none local
- Curve
- Modelica
|- Curve // Fscurve refers to this class
|- Mechanics
|- Spring
|- Foo
The benefit of that mechanism is, that you can use short class names when you are working inside a package and you don't have to type the full class path (but you always can). If you have e.g. an electrical package
- Electrical
|- Ground
|- Resistor
|- Inductor
|- RL_Circuit
the example RL_Circuit could look like that:
model RL_Circuit
Ground ground;
Resistor R1;
Electrical.Resistor R2; // refers to the same class as R1, but using its full name
Inductor L1;
equation
connect ...
end RL_Circuit;
Related
num_labels = 3 if task.startswith("mnli") else 1 if task=="stsb" else 2
preconfig = DistilBertConfig(n_layers=6)
model1 = AutoModelForSequenceClassification.from_config(preconfig)
model2 = AutoModelForSequenceClassification.from_pretrained(model_checkpoint, num_labels=num_labels)
I am modifying this code (modified code is provided above) to test DistilBERT transformer layer depth size via from_config since from my knowledge from_pretrained uses 6 layers because in the paper section 3 they said:
we initialize the student from the teacher by taking one layer out of two
While what I want to test is various sizes of layers. To test whether both are the same, I tried running the from_config
with n_layers=6 because based on the documentation DistilBertConfig the n_layers is used to determine the transformer block depth. However as I run model1 and model2 I found that with SST-2 dataset, in accuracy:
model1 achieved only 0.8073
model2 achieved 0.901
If they both behave the same I expect the result to be somewhat similar but 10% drop is a significant drop, therefore I believe there ha to be a difference between the functions. Is there a reason behind the difference of the approach (for example model1 has not yet applied hyperparameter search) and is there a way to make both functions behave the same? Thank you!
The two functions you described, from_config and from_pretrained, do not behave the same. For a model M, with a reference R:
from_config allows you to instantiate a blank model, which has the same configuration (the same shape) as your model of choice: M is as R was before training
from_pretrained allows you to load a pretrained model, which has already been trained on a specific dataset for a given number of epochs: M is as R after training.
To cite the doc, Note: Loading a model from its configuration file does not load the model weights. It only affects the model’s configuration. Use from_pretrained() to load the model weights.
I'm trying to design a UML class diagram that represents Users that interact with other classes based on their roles, I've chosen to represent Roles as an enum class like so :
What i'd like to represent is that only a user with a Role ADMIN can create a project, only a MANAGER can modify it and every CONSULTANT can only participate in it, can this be achievable with enum representation for Roles?
A solution is to use uml constraints like so:
Being an enumeration RoleName is better drawn with <<enumeration>> (like in the Figure 7.1 - Class Diagram Example page 7 of Object Constraint Language - formal/2014-02-03 )
If Role is only an envelop for RoleName that class is useless (this is what I suppose in the diagram below)
The relations create, manage, participate do not represent attributes, the multiplicities have non sense in that context. The relation role has the default multiplicity 1
Your constraints are pre-conditions, their context is the class User and in OCL the equality operator is "=", so your diagram can be :
You are mixing static representation and behavior. The User has one association to Project (not 3 different ones):
The different behavior (derived from some UC) can be shown in a collaboration. E.g. in an AD like this:
Just a sketch, but that should give you the gist.
I'm using IBM Rational Rose, but I'm not sure if I'm able to model/design the methods/procedures which are known as "operations" within a class onto "UML User Class Diagram". Is there any way to model the algorithm or the code of 'operations' (i.e something like flowchart) via the software? If so, is there any possibility to get the methods design auto-implementation integrated via code generation in order to define them within a java source file?
Another way to model behavior is to use StateMachine, Constraints, Sequence and Timing diagrams. Of course, you can simply write Notes describing behavior in plain words.
You can use activity diagram, activity diagrams are near a flow chart.
See rsa activity diagram
On your activity diagram, you create a partition and you can link your partition to you operation. Then you create callOperation action which can be linked to method call.
I create a class diagram with 4 class Class1, Class2, Class3, Class4, each one containing a method operationx.
And here is a simple example modeling operation1. The important point is that the partition named Operation1 is linked in the UML model to Class1:operation1 and the 3 actions are linked to method operations. This is not a "typo" tips.
You can look also to sequences diargam but it does not look like a flow chart.
I develop similar calculation packages for different clients (Bob, Rick, Sue, Eve). The calculation packages consist of several calculation modules (A, B, C, D, ...), which are organized in a "Chain of responsibility" pattern. Assembly is done with Abstract factory.
As a lot of code is shared between the calculation modules of different clients, they are organized in an hierarchy:
ICalcA
|
AbstrCalcA
| |
AbstrCalcAMale AbstrCalcAFemale
| | | |
CalcABob CalcARick CalcASue CalcAEve
(same hierarchy for B, C, D, ...).
Now release management dictates, that I organize the source code per inheritance level:
Project: CalcCommon
[CalcA]
ICalcA.cs
AbstrCalcA.cs
[CalcB]
ICalcB.cs
AbstrCalcB.cs
[CalcC]
...
Project: CalcMale
[CalcA]
AbstrCalcAMale.cs
[CalcB]
AbstrCalcBMale.cs
[CalcC]
....
Project: CalcBob
[CalcA]
CalcABob.cs
[CalcB]
CalcBBob.cs
[CalcC]
....
Project: CalcFemale
....
For Bob, I release CommonCalc.dll, CalcMale.dll and CalcBob.dll.
Now this is all good, but with many modules, helper classes, and so on, it is very cumbersome to work within the same module hierarchy. Closely related classes (e.g. ICalcA and CalcABob) are far away in the solution explorer. No one on my teams seems to find anything without searching for the class name -- if he can remember it. Features tend to get implemented in wrong or multiple hierarchy levels.
How can I improve the situation?
I was thinking of creating one project per Module and hierarchy level (Projects: CalcCommonA, CalcMaleA, CalcBobA, CalcRickA, CalcCommonB, CalcMaleB, ...), and grouping them via solution folders.
I just found out that the new search bar on top of the solution explorer comes in handy for this.
Step 1: Make sure all classes related to Feature A contain "FeatureA" in their class name.
Step 2: If working in the FeatureA hierarchy, enter "FeatureA" into the search/filter bar.
This will display just to the classes of this particular hierarchy, just as required.
I have a couple modules. They communicate to each other through events.
What UML diagram would typically be used to show this?
Is there a non uml diagram people use?
Any examples?
I think you definitely want a sequence diagram to show all the event interaction between modules in sequence. This is the preferred way to represent sequence of asynchronous messages between components
If you want to express the fact that a module A fires an event E that is handled by module B, I suggest a static diagram to show the structure of your architecture.
In particular, I would use a class diagram where I could draw:
the modules A and B (classes with a stereotype)
the event E (i.e. still a class with the stereotype event)
an association named subscribe between B and E
an association named publish between A and E.
In general you want to use a "behavioral" diagram(s). There are multiple flavors. Which one you choose depends on the intent of what a given diagram wants to convey.
http://www.visual-paradigm.com/product/vpuml/provides/behavioralmodeling.jsp