forked from deeplearning4j/deeplearning4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into mp_weight_init_objects
- Loading branch information
Showing
2 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
...ning4j-nn/src/main/java/org/deeplearning4j/nn/conf/distribution/ConstantDistribution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/*- | ||
* | ||
* * Copyright 2015 Skymind,Inc. | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package org.deeplearning4j.nn.conf.distribution; | ||
|
||
import org.nd4j.shade.jackson.annotation.JsonCreator; | ||
import org.nd4j.shade.jackson.annotation.JsonProperty; | ||
|
||
/** | ||
* Constant distribution. | ||
* | ||
*/ | ||
public class ConstantDistribution extends Distribution { | ||
|
||
private double value; | ||
|
||
/** | ||
* Create a Constant distribution with given value | ||
* | ||
* @param value the gain | ||
*/ | ||
@JsonCreator | ||
public ConstantDistribution(@JsonProperty("value") double value) { | ||
this.value = value; | ||
} | ||
|
||
public double getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(double value) { | ||
this.value = value; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
long temp; | ||
temp = Double.doubleToLongBits(value); | ||
result = prime * result + (int) (temp ^ (temp >>> 32)); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
ConstantDistribution other = (ConstantDistribution) obj; | ||
if (Double.doubleToLongBits(value) != Double.doubleToLongBits(other.value)) | ||
return false; | ||
return true; | ||
} | ||
|
||
public String toString() { | ||
return "ConstantDistribution{value=" + value + "}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters