Skip to content

Commit

Permalink
Fix NPE bug in block.toString() function
Browse files Browse the repository at this point in the history
Change-Id: I2aa8bc6c8d36d01cc00c02778907b040d782330c
  • Loading branch information
frankfliu committed Jul 5, 2021
1 parent 7a7f41f commit 122c355
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion api/src/main/java/ai/djl/nn/AbstractBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public final NDList forward(
boolean training,
PairList<String, Object> params) {
NDManager paramsManager = parameterStore.getManager();
if (!isInitialized()) {
if (training && !isInitialized()) {
initialize(paramsManager, DataType.FLOAT32, inputs.getShapes());
}
return forwardInternal(parameterStore, inputs, training, params);
Expand Down Expand Up @@ -330,6 +330,9 @@ protected void prepare(Shape[] inputShapes) {}
/** {@inheritDoc} */
@Override
public boolean isInitialized() {
if (inputShapes == null) {
return false;
}
for (Parameter param : getParameters().values()) {
if (!param.isInitialized()) {
return false;
Expand Down

0 comments on commit 122c355

Please sign in to comment.