Skip to content
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

More refactoring #92

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Sources/Adapters/TFOptimizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public extension TFOptimizer {
/// This information can later be used by the 'activationNeuron' function
func addNeuronIfThere(node: TFNode) {
let outgoing = node.outgoingNodes()
if outgoing.count == 1, let next = (outgoing.first as? TFNode),
if let next = (outgoing.first as? TFNode),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we don't want to remove this check. There could be more than one outgoingNodes

next.nodeDef.isTFReLuOp || next.nodeDef.isTFTanhOp || next.nodeDef.isTFSigmoidOp {
var neuron = Tensorflow_AttrValue()
neuron.value = Tensorflow_AttrValue.OneOf_Value.s(next.nodeDef.op.data(using: .utf8)!)
Expand Down
6 changes: 3 additions & 3 deletions Sources/Core/Network.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public class Network {

func set(layers: [NetworkLayer]) {
nodes = layers
let inputNodes = nodes.filter { $0.getIncoming().count == 0 }
let inputNodes = nodes.filter { $0.getIncoming().isEmpty }
assert(inputNodes.count == startNodes.count, "Number of network inputs(\(inputNodes.count)) and input sizes(\(startNodes.count)) are not equal")
if inputNodes.count == 1 {
inputNodes[0].addIncomingEdge(from: startNodes[0])
if let first = inputNodes.first {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not correct. If there are many inputNodes we want to go into the else

first.addIncomingEdge(from: startNodes[0])
nodes.insert(startNodes[0], at: 0)
} else {
for node in startNodes {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/ParameterLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extension ParameterLoader {
let w = UnsafePointer(hdrW!.bindMemory(to: Float.self, capacity: Int(sizeWeights)))

close(fd_w)
assert(w != UnsafePointer<Float>.init(bitPattern: -1), "mmap failed with errno = \(errno)")
assert(w != UnsafePointer<Float>(bitPattern: -1), "mmap failed with errno = \(errno)")
return w
}

Expand Down