-
Notifications
You must be signed in to change notification settings - Fork 126
[NeoML] CDnnHeadAdapterLayer #1058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
// Which of the blobs will be used during learn | ||
int blobsForLearn; | ||
// Save first adapter name to connect to necessary head in serialization | ||
CString firstAdapter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the first adapter will be removed from the dnn?
|
||
auto headSource = static_cast<CCompositeSourceLayer*>(internalDnn->GetLayer("source").Ptr()); | ||
headSource->SetBlob(inputBlobs[0]); | ||
internalDnn->runOnce( 0 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The special test should be where the CDnnHeadAdapterLayer
is inside the CRecursiveLayer
.
|
||
using namespace NeoML; | ||
using namespace NeoMLTest; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, add one more test with the exact scenario suggested by the user of this feature
IMathEngine& mathEngine = MathEngine();
CRandom random( 42 );
CDnn dnn( random, mathEngine );
// To be able run the same set of layers 3 times
// on 3 different inputs to get 3 different outputs links
CPtr<CDnnHead> head = new CDnnHead<
CFullyConnectedLayer,
CGELULayer,
CFullyConnectedLayer,
CReLULayer,
CDropoutLayer,
CFullyConnectedLayer
>(
random, mathEngine,
FullyConnected( 128 ),
Gelu(),
FullyConnected( 64 ),
Relu(),
Dropout( 0.5f ),
FullyConnected( 1 )
);
CBaseLayer* x = Source( dnn, "srcX" );
x = FullyConnected( 512 )( x );
x = Gelu()( x );
x = DnnHeadAdapter( head )( x ); // #1 head dnn call
CBaseLayer* y = Source( dnn, "srcY" );
y = FullyConnected( 512 )( y );
y = Gelu()( y );
y = DnnHeadAdapter( head )( y ); // #2 head dnn call
CBaseLayer* z = Source( dnn, "srcZ" );
z = FullyConnected( 512 )( z );
z = Gelu()( z );
z = DnnHeadAdapter( head )( z ); // #3 head dnn call
CBaseLayer* out = ConcatChannels()( x, y, z );
CBaseLayer* labels = Source( dnn, "labels" );
BinaryCrossEntropyLoss()( out, labels );
NeoML/src/Dnn/DnnOptimization.cpp
Outdated
CDnnHeadAdapterLayer* head = dynamic_cast<CDnnHeadAdapterLayer*>(layer); | ||
if (head != nullptr) | ||
{ | ||
OptimizeDnn(*(head->GetDnnHead()->GetInnerDnn())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is a only one adapter for this exact sub-network, this adapter should be removed and sub-net reconnected directly, as it works for a composite in the optimization::UnpackComposites
.
c77fccb
to
dcbedff
Compare
… repeats Signed-off-by: Kirill Golikov <[email protected]>
Signed-off-by: daniyalaliev <[email protected]>
Signed-off-by: Kirill Golikov <[email protected]>
Signed-off-by: Kirill Golikov <[email protected]>
Signed-off-by: Kirill Golikov <[email protected]>
Signed-off-by: Kirill Golikov <[email protected]>
Signed-off-by: Kirill Golikov <[email protected]>
Signed-off-by: Kirill Golikov <[email protected]>
No description provided.