Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
C
CNNArch2Gluon
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
monticore
EmbeddedMontiArc
generators
CNNArch2Gluon
Commits
72b82633
Commit
72b82633
authored
Oct 30, 2019
by
Sebastian N.
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated tests
parent
d6185b6e
Pipeline
#200193
failed with stages
in 19 seconds
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
243 additions
and
12 deletions
+243
-12
src/test/resources/target_code/CNNNet_Alexnet.py
src/test/resources/target_code/CNNNet_Alexnet.py
+11
-1
src/test/resources/target_code/CNNNet_CifarClassifierNetwork.py
...st/resources/target_code/CNNNet_CifarClassifierNetwork.py
+11
-1
src/test/resources/target_code/CNNNet_VGG16.py
src/test/resources/target_code/CNNNet_VGG16.py
+11
-1
src/test/resources/target_code/CNNSupervisedTrainer_Alexnet.py
...est/resources/target_code/CNNSupervisedTrainer_Alexnet.py
+60
-3
src/test/resources/target_code/CNNSupervisedTrainer_CifarClassifierNetwork.py
...arget_code/CNNSupervisedTrainer_CifarClassifierNetwork.py
+60
-3
src/test/resources/target_code/CNNSupervisedTrainer_VGG16.py
src/test/resources/target_code/CNNSupervisedTrainer_VGG16.py
+60
-3
src/test/resources/target_code/ddpg/reinforcement_learning/CNNNet_CriticNetwork.py
..._code/ddpg/reinforcement_learning/CNNNet_CriticNetwork.py
+10
-0
src/test/resources/target_code/ros-ddpg/reinforcement_learning/CNNNet_RosCriticNetwork.py
...os-ddpg/reinforcement_learning/CNNNet_RosCriticNetwork.py
+10
-0
src/test/resources/target_code/td3/reinforcement_learning/CNNNet_CriticNetwork.py
...t_code/td3/reinforcement_learning/CNNNet_CriticNetwork.py
+10
-0
No files found.
src/test/resources/target_code/CNNNet_Alexnet.py
View file @
72b82633
...
...
@@ -40,6 +40,16 @@ class NoNormalization(gluon.HybridBlock):
return
x
class
Reshape
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
shape
,
**
kwargs
):
super
(
Reshape
,
self
).
__init__
(
**
kwargs
)
with
self
.
name_scope
():
self
.
shape
=
shape
def
hybrid_forward
(
self
,
F
,
x
):
return
F
.
reshape
(
data
=
x
,
shape
=
self
.
shape
)
class
CustomRNN
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
hidden_size
,
num_layers
,
bidirectional
,
**
kwargs
):
super
(
CustomRNN
,
self
).
__init__
(
**
kwargs
)
...
...
@@ -253,7 +263,7 @@ class Net_0(gluon.HybridBlock):
relu7_
=
self
.
relu7_
(
fc7_
)
dropout7_
=
self
.
dropout7_
(
relu7_
)
fc8_
=
self
.
fc8_
(
dropout7_
)
softmax8_
=
F
.
softmax
(
fc8_
)
softmax8_
=
F
.
softmax
(
fc8_
,
axis
=-
1
)
predictions_
=
softmax8_
return
predictions_
...
...
src/test/resources/target_code/CNNNet_CifarClassifierNetwork.py
View file @
72b82633
...
...
@@ -40,6 +40,16 @@ class NoNormalization(gluon.HybridBlock):
return
x
class
Reshape
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
shape
,
**
kwargs
):
super
(
Reshape
,
self
).
__init__
(
**
kwargs
)
with
self
.
name_scope
():
self
.
shape
=
shape
def
hybrid_forward
(
self
,
F
,
x
):
return
F
.
reshape
(
data
=
x
,
shape
=
self
.
shape
)
class
CustomRNN
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
hidden_size
,
num_layers
,
bidirectional
,
**
kwargs
):
super
(
CustomRNN
,
self
).
__init__
(
**
kwargs
)
...
...
@@ -460,7 +470,7 @@ class Net_0(gluon.HybridBlock):
fc31_
=
self
.
fc31_
(
globalpooling31_
)
dropout31_
=
self
.
dropout31_
(
fc31_
)
fc32_
=
self
.
fc32_
(
dropout31_
)
softmax32_
=
F
.
softmax
(
fc32_
)
softmax32_
=
F
.
softmax
(
fc32_
,
axis
=-
1
)
softmax_
=
softmax32_
return
softmax_
...
...
src/test/resources/target_code/CNNNet_VGG16.py
View file @
72b82633
...
...
@@ -40,6 +40,16 @@ class NoNormalization(gluon.HybridBlock):
return
x
class
Reshape
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
shape
,
**
kwargs
):
super
(
Reshape
,
self
).
__init__
(
**
kwargs
)
with
self
.
name_scope
():
self
.
shape
=
shape
def
hybrid_forward
(
self
,
F
,
x
):
return
F
.
reshape
(
data
=
x
,
shape
=
self
.
shape
)
class
CustomRNN
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
hidden_size
,
num_layers
,
bidirectional
,
**
kwargs
):
super
(
CustomRNN
,
self
).
__init__
(
**
kwargs
)
...
...
@@ -285,7 +295,7 @@ class Net_0(gluon.HybridBlock):
relu15_
=
self
.
relu15_
(
fc14_
)
dropout15_
=
self
.
dropout15_
(
relu15_
)
fc15_
=
self
.
fc15_
(
dropout15_
)
softmax15_
=
F
.
softmax
(
fc15_
)
softmax15_
=
F
.
softmax
(
fc15_
,
axis
=-
1
)
predictions_
=
softmax15_
return
predictions_
...
...
src/test/resources/target_code/CNNSupervisedTrainer_Alexnet.py
View file @
72b82633
...
...
@@ -34,6 +34,30 @@ class LogCoshLoss(gluon.loss.Loss):
loss
=
gluon
.
loss
.
_apply_weighting
(
F
,
loss
,
self
.
_weight
,
sample_weight
)
return
F
.
mean
(
loss
,
axis
=
self
.
_batch_axis
,
exclude
=
True
)
class
SoftmaxCrossEntropyLossIgnoreIndices
(
gluon
.
loss
.
Loss
):
def
__init__
(
self
,
axis
=-
1
,
ignore_indices
=
[],
sparse_label
=
True
,
from_logits
=
False
,
weight
=
None
,
batch_axis
=
0
,
**
kwargs
):
super
(
SoftmaxCrossEntropyLossIgnoreIndices
,
self
).
__init__
(
weight
,
batch_axis
,
**
kwargs
)
self
.
_axis
=
axis
self
.
_ignore_indices
=
ignore_indices
self
.
_sparse_label
=
sparse_label
self
.
_from_logits
=
from_logits
def
hybrid_forward
(
self
,
F
,
pred
,
label
,
sample_weight
=
None
):
log_softmax
=
F
.
log_softmax
pick
=
F
.
pick
if
not
self
.
_from_logits
:
pred
=
log_softmax
(
pred
,
self
.
_axis
)
if
self
.
_sparse_label
:
loss
=
-
pick
(
pred
,
label
,
axis
=
self
.
_axis
,
keepdims
=
True
)
else
:
label
=
_reshape_like
(
F
,
label
,
pred
)
loss
=
-
(
pred
*
label
).
sum
(
axis
=
self
.
_axis
,
keepdims
=
True
)
#loss = _apply_weighting(F, loss, self._weight, sample_weight)
# ignore some indices for loss, e.g. <pad> tokens in NLP applications
for
i
in
self
.
_ignore_indices
:
loss
=
loss
*
mx
.
nd
.
logical_not
(
mx
.
nd
.
equal
(
mx
.
nd
.
argmax
(
pred
,
axis
=
1
),
mx
.
nd
.
ones_like
(
mx
.
nd
.
argmax
(
pred
,
axis
=
1
))
*
i
))
return
loss
.
mean
(
axis
=
self
.
_batch_axis
,
exclude
=
True
)
@
mx
.
metric
.
register
class
BLEU
(
mx
.
metric
.
EvalMetric
):
N
=
4
...
...
@@ -144,6 +168,8 @@ class BLEU(mx.metric.EvalMetric):
return
new_list
class
CNNSupervisedTrainer_Alexnet
:
def
applyBeamSearch
(
input
,
length
,
width
,
maxLength
,
currProb
,
netIndex
,
bestOutput
):
bestProb
=
0.0
...
...
@@ -334,12 +360,43 @@ class CNNSupervisedTrainer_Alexnet:
predictions
=
[]
for
output_name
in
outputs
:
if
mx
.
nd
.
shape_array
(
output_name
).
size
>
1
:
if
mx
.
nd
.
shape_array
(
mx
.
nd
.
squeeze
(
output_name
)
).
size
>
1
:
predictions
.
append
(
mx
.
nd
.
argmax
(
output_name
,
axis
=
1
))
#ArgMax already applied
else
:
predictions
.
append
(
output_name
)
'''
#Compute BLEU and NIST Score if data folder contains a dictionary -> NLP dataset
if(os.path.isfile('src/test/resources/training_data/Show_attend_tell/dict.pkl')):
with open('src/test/resources/training_data/Show_attend_tell/dict.pkl', 'rb') as f:
dict = pickle.load(f)
import nltk.translate.bleu_score
import nltk.translate.nist_score
prediction = []
for index in range(batch_size):
sentence = ''
for entry in predictions:
sentence += dict[int(entry[index].asscalar())] + ' '
prediction.append(sentence)
for index in range(batch_size):
sentence = ''
for batchEntry in batch.label:
sentence += dict[int(batchEntry[index].asscalar())] + ' '
print("############################")
print("label1: ", sentence)
print("prediction1: ", prediction[index])
BLEUscore = nltk.translate.bleu_score.sentence_bleu([sentence], prediction[index])
NISTscore = nltk.translate.nist_score.sentence_nist([sentence], prediction[index])
print("BLEU: ", BLEUscore)
print("NIST: ", NISTscore)
print("############################")
'''
metric
.
update
(
preds
=
predictions
,
labels
=
labels
)
train_metric_score
=
metric
.
get
()[
1
]
...
...
@@ -354,7 +411,7 @@ class CNNSupervisedTrainer_Alexnet:
outputs
=
[]
if
True
:
if
True
:
predictions_
=
mx
.
nd
.
zeros
((
batch_size
,
10
,),
ctx
=
mx_context
)
predictions_
=
self
.
_networks
[
0
](
data_
)
...
...
@@ -362,7 +419,7 @@ class CNNSupervisedTrainer_Alexnet:
predictions
=
[]
for
output_name
in
outputs
:
if
mx
.
nd
.
shape_array
(
output_name
).
size
>
1
:
if
mx
.
nd
.
shape_array
(
mx
.
nd
.
squeeze
(
output_name
)
).
size
>
1
:
predictions
.
append
(
mx
.
nd
.
argmax
(
output_name
,
axis
=
1
))
#ArgMax already applied
else
:
...
...
src/test/resources/target_code/CNNSupervisedTrainer_CifarClassifierNetwork.py
View file @
72b82633
...
...
@@ -34,6 +34,30 @@ class LogCoshLoss(gluon.loss.Loss):
loss
=
gluon
.
loss
.
_apply_weighting
(
F
,
loss
,
self
.
_weight
,
sample_weight
)
return
F
.
mean
(
loss
,
axis
=
self
.
_batch_axis
,
exclude
=
True
)
class
SoftmaxCrossEntropyLossIgnoreIndices
(
gluon
.
loss
.
Loss
):
def
__init__
(
self
,
axis
=-
1
,
ignore_indices
=
[],
sparse_label
=
True
,
from_logits
=
False
,
weight
=
None
,
batch_axis
=
0
,
**
kwargs
):
super
(
SoftmaxCrossEntropyLossIgnoreIndices
,
self
).
__init__
(
weight
,
batch_axis
,
**
kwargs
)
self
.
_axis
=
axis
self
.
_ignore_indices
=
ignore_indices
self
.
_sparse_label
=
sparse_label
self
.
_from_logits
=
from_logits
def
hybrid_forward
(
self
,
F
,
pred
,
label
,
sample_weight
=
None
):
log_softmax
=
F
.
log_softmax
pick
=
F
.
pick
if
not
self
.
_from_logits
:
pred
=
log_softmax
(
pred
,
self
.
_axis
)
if
self
.
_sparse_label
:
loss
=
-
pick
(
pred
,
label
,
axis
=
self
.
_axis
,
keepdims
=
True
)
else
:
label
=
_reshape_like
(
F
,
label
,
pred
)
loss
=
-
(
pred
*
label
).
sum
(
axis
=
self
.
_axis
,
keepdims
=
True
)
#loss = _apply_weighting(F, loss, self._weight, sample_weight)
# ignore some indices for loss, e.g. <pad> tokens in NLP applications
for
i
in
self
.
_ignore_indices
:
loss
=
loss
*
mx
.
nd
.
logical_not
(
mx
.
nd
.
equal
(
mx
.
nd
.
argmax
(
pred
,
axis
=
1
),
mx
.
nd
.
ones_like
(
mx
.
nd
.
argmax
(
pred
,
axis
=
1
))
*
i
))
return
loss
.
mean
(
axis
=
self
.
_batch_axis
,
exclude
=
True
)
@
mx
.
metric
.
register
class
BLEU
(
mx
.
metric
.
EvalMetric
):
N
=
4
...
...
@@ -144,6 +168,8 @@ class BLEU(mx.metric.EvalMetric):
return
new_list
class
CNNSupervisedTrainer_CifarClassifierNetwork
:
def
applyBeamSearch
(
input
,
length
,
width
,
maxLength
,
currProb
,
netIndex
,
bestOutput
):
bestProb
=
0.0
...
...
@@ -334,12 +360,43 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
predictions
=
[]
for
output_name
in
outputs
:
if
mx
.
nd
.
shape_array
(
output_name
).
size
>
1
:
if
mx
.
nd
.
shape_array
(
mx
.
nd
.
squeeze
(
output_name
)
).
size
>
1
:
predictions
.
append
(
mx
.
nd
.
argmax
(
output_name
,
axis
=
1
))
#ArgMax already applied
else
:
predictions
.
append
(
output_name
)
'''
#Compute BLEU and NIST Score if data folder contains a dictionary -> NLP dataset
if(os.path.isfile('src/test/resources/training_data/Show_attend_tell/dict.pkl')):
with open('src/test/resources/training_data/Show_attend_tell/dict.pkl', 'rb') as f:
dict = pickle.load(f)
import nltk.translate.bleu_score
import nltk.translate.nist_score
prediction = []
for index in range(batch_size):
sentence = ''
for entry in predictions:
sentence += dict[int(entry[index].asscalar())] + ' '
prediction.append(sentence)
for index in range(batch_size):
sentence = ''
for batchEntry in batch.label:
sentence += dict[int(batchEntry[index].asscalar())] + ' '
print("############################")
print("label1: ", sentence)
print("prediction1: ", prediction[index])
BLEUscore = nltk.translate.bleu_score.sentence_bleu([sentence], prediction[index])
NISTscore = nltk.translate.nist_score.sentence_nist([sentence], prediction[index])
print("BLEU: ", BLEUscore)
print("NIST: ", NISTscore)
print("############################")
'''
metric
.
update
(
preds
=
predictions
,
labels
=
labels
)
train_metric_score
=
metric
.
get
()[
1
]
...
...
@@ -354,7 +411,7 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
outputs
=
[]
if
True
:
if
True
:
softmax_
=
mx
.
nd
.
zeros
((
batch_size
,
10
,),
ctx
=
mx_context
)
softmax_
=
self
.
_networks
[
0
](
data_
)
...
...
@@ -362,7 +419,7 @@ class CNNSupervisedTrainer_CifarClassifierNetwork:
predictions
=
[]
for
output_name
in
outputs
:
if
mx
.
nd
.
shape_array
(
output_name
).
size
>
1
:
if
mx
.
nd
.
shape_array
(
mx
.
nd
.
squeeze
(
output_name
)
).
size
>
1
:
predictions
.
append
(
mx
.
nd
.
argmax
(
output_name
,
axis
=
1
))
#ArgMax already applied
else
:
...
...
src/test/resources/target_code/CNNSupervisedTrainer_VGG16.py
View file @
72b82633
...
...
@@ -34,6 +34,30 @@ class LogCoshLoss(gluon.loss.Loss):
loss
=
gluon
.
loss
.
_apply_weighting
(
F
,
loss
,
self
.
_weight
,
sample_weight
)
return
F
.
mean
(
loss
,
axis
=
self
.
_batch_axis
,
exclude
=
True
)
class
SoftmaxCrossEntropyLossIgnoreIndices
(
gluon
.
loss
.
Loss
):
def
__init__
(
self
,
axis
=-
1
,
ignore_indices
=
[],
sparse_label
=
True
,
from_logits
=
False
,
weight
=
None
,
batch_axis
=
0
,
**
kwargs
):
super
(
SoftmaxCrossEntropyLossIgnoreIndices
,
self
).
__init__
(
weight
,
batch_axis
,
**
kwargs
)
self
.
_axis
=
axis
self
.
_ignore_indices
=
ignore_indices
self
.
_sparse_label
=
sparse_label
self
.
_from_logits
=
from_logits
def
hybrid_forward
(
self
,
F
,
pred
,
label
,
sample_weight
=
None
):
log_softmax
=
F
.
log_softmax
pick
=
F
.
pick
if
not
self
.
_from_logits
:
pred
=
log_softmax
(
pred
,
self
.
_axis
)
if
self
.
_sparse_label
:
loss
=
-
pick
(
pred
,
label
,
axis
=
self
.
_axis
,
keepdims
=
True
)
else
:
label
=
_reshape_like
(
F
,
label
,
pred
)
loss
=
-
(
pred
*
label
).
sum
(
axis
=
self
.
_axis
,
keepdims
=
True
)
#loss = _apply_weighting(F, loss, self._weight, sample_weight)
# ignore some indices for loss, e.g. <pad> tokens in NLP applications
for
i
in
self
.
_ignore_indices
:
loss
=
loss
*
mx
.
nd
.
logical_not
(
mx
.
nd
.
equal
(
mx
.
nd
.
argmax
(
pred
,
axis
=
1
),
mx
.
nd
.
ones_like
(
mx
.
nd
.
argmax
(
pred
,
axis
=
1
))
*
i
))
return
loss
.
mean
(
axis
=
self
.
_batch_axis
,
exclude
=
True
)
@
mx
.
metric
.
register
class
BLEU
(
mx
.
metric
.
EvalMetric
):
N
=
4
...
...
@@ -144,6 +168,8 @@ class BLEU(mx.metric.EvalMetric):
return
new_list
class
CNNSupervisedTrainer_VGG16
:
def
applyBeamSearch
(
input
,
length
,
width
,
maxLength
,
currProb
,
netIndex
,
bestOutput
):
bestProb
=
0.0
...
...
@@ -334,12 +360,43 @@ class CNNSupervisedTrainer_VGG16:
predictions
=
[]
for
output_name
in
outputs
:
if
mx
.
nd
.
shape_array
(
output_name
).
size
>
1
:
if
mx
.
nd
.
shape_array
(
mx
.
nd
.
squeeze
(
output_name
)
).
size
>
1
:
predictions
.
append
(
mx
.
nd
.
argmax
(
output_name
,
axis
=
1
))
#ArgMax already applied
else
:
predictions
.
append
(
output_name
)
'''
#Compute BLEU and NIST Score if data folder contains a dictionary -> NLP dataset
if(os.path.isfile('src/test/resources/training_data/Show_attend_tell/dict.pkl')):
with open('src/test/resources/training_data/Show_attend_tell/dict.pkl', 'rb') as f:
dict = pickle.load(f)
import nltk.translate.bleu_score
import nltk.translate.nist_score
prediction = []
for index in range(batch_size):
sentence = ''
for entry in predictions:
sentence += dict[int(entry[index].asscalar())] + ' '
prediction.append(sentence)
for index in range(batch_size):
sentence = ''
for batchEntry in batch.label:
sentence += dict[int(batchEntry[index].asscalar())] + ' '
print("############################")
print("label1: ", sentence)
print("prediction1: ", prediction[index])
BLEUscore = nltk.translate.bleu_score.sentence_bleu([sentence], prediction[index])
NISTscore = nltk.translate.nist_score.sentence_nist([sentence], prediction[index])
print("BLEU: ", BLEUscore)
print("NIST: ", NISTscore)
print("############################")
'''
metric
.
update
(
preds
=
predictions
,
labels
=
labels
)
train_metric_score
=
metric
.
get
()[
1
]
...
...
@@ -354,7 +411,7 @@ class CNNSupervisedTrainer_VGG16:
outputs
=
[]
if
True
:
if
True
:
predictions_
=
mx
.
nd
.
zeros
((
batch_size
,
1000
,),
ctx
=
mx_context
)
predictions_
=
self
.
_networks
[
0
](
data_
)
...
...
@@ -362,7 +419,7 @@ class CNNSupervisedTrainer_VGG16:
predictions
=
[]
for
output_name
in
outputs
:
if
mx
.
nd
.
shape_array
(
output_name
).
size
>
1
:
if
mx
.
nd
.
shape_array
(
mx
.
nd
.
squeeze
(
output_name
)
).
size
>
1
:
predictions
.
append
(
mx
.
nd
.
argmax
(
output_name
,
axis
=
1
))
#ArgMax already applied
else
:
...
...
src/test/resources/target_code/ddpg/reinforcement_learning/CNNNet_CriticNetwork.py
View file @
72b82633
...
...
@@ -40,6 +40,16 @@ class NoNormalization(gluon.HybridBlock):
return
x
class
Reshape
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
shape
,
**
kwargs
):
super
(
Reshape
,
self
).
__init__
(
**
kwargs
)
with
self
.
name_scope
():
self
.
shape
=
shape
def
hybrid_forward
(
self
,
F
,
x
):
return
F
.
reshape
(
data
=
x
,
shape
=
self
.
shape
)
class
CustomRNN
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
hidden_size
,
num_layers
,
bidirectional
,
**
kwargs
):
super
(
CustomRNN
,
self
).
__init__
(
**
kwargs
)
...
...
src/test/resources/target_code/ros-ddpg/reinforcement_learning/CNNNet_RosCriticNetwork.py
View file @
72b82633
...
...
@@ -40,6 +40,16 @@ class NoNormalization(gluon.HybridBlock):
return
x
class
Reshape
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
shape
,
**
kwargs
):
super
(
Reshape
,
self
).
__init__
(
**
kwargs
)
with
self
.
name_scope
():
self
.
shape
=
shape
def
hybrid_forward
(
self
,
F
,
x
):
return
F
.
reshape
(
data
=
x
,
shape
=
self
.
shape
)
class
CustomRNN
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
hidden_size
,
num_layers
,
bidirectional
,
**
kwargs
):
super
(
CustomRNN
,
self
).
__init__
(
**
kwargs
)
...
...
src/test/resources/target_code/td3/reinforcement_learning/CNNNet_CriticNetwork.py
View file @
72b82633
...
...
@@ -40,6 +40,16 @@ class NoNormalization(gluon.HybridBlock):
return
x
class
Reshape
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
shape
,
**
kwargs
):
super
(
Reshape
,
self
).
__init__
(
**
kwargs
)
with
self
.
name_scope
():
self
.
shape
=
shape
def
hybrid_forward
(
self
,
F
,
x
):
return
F
.
reshape
(
data
=
x
,
shape
=
self
.
shape
)
class
CustomRNN
(
gluon
.
HybridBlock
):
def
__init__
(
self
,
hidden_size
,
num_layers
,
bidirectional
,
**
kwargs
):
super
(
CustomRNN
,
self
).
__init__
(
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment