Skip to content

Commit 5077937

Browse files
1.0.0 breaking changes (#65)
* 1.0.0 breaking changes * ignore versions for now
1 parent 0f695b0 commit 5077937

File tree

12 files changed

+22
-21
lines changed

12 files changed

+22
-21
lines changed

.github/workflows/crystal.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
steps:
1414
- uses: actions/checkout@v1
1515
- name: Install dependencies
16-
run: shards install
16+
run: shards install --ignore-crystal-version
1717
- name: Run tests
1818
run: crystal spec

shard.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: num
2-
version: 0.4.4
2+
version: 0.4.5
33

44
authors:
55
- Chris Zimmerman <[email protected]>
66

7-
crystal: 0.35.1
7+
crystal: 1.0.0
88

99
license: MIT
1010

@@ -13,6 +13,7 @@ dependencies:
1313
github: crystal-data/opencl.cr
1414
alea:
1515
github: nin93/alea
16+
branch: master
1617

1718
scripts:
1819
postinstall: make ext

src/grad/gates_blas.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class Num::Grad::MatMulGate(T) < Num::Grad::Gate(T)
4141
end
4242

4343
# :nodoc:
44-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
44+
def cache(result : Num::Grad::Variable(T), *args)
4545
a, b = args
4646

4747
result.grad = T.zeros_like(result.value)

src/nn/gates/elu.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Num::NN::EluGate(T) < Num::Grad::Gate(T)
3232
[Num::NN.elu_prime(gradient, @cache)]
3333
end
3434

35-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
35+
def cache(result : Num::Grad::Variable(T), *args)
3636
result.grad = T.zeros_like(result.value)
3737
result.requires_grad = true
3838

src/nn/gates/input.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Num::NN::InputGate(T) < Num::Grad::Gate(T)
3030
[gradient]
3131
end
3232

33-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
33+
def cache(result : Num::Grad::Variable(T), *args)
3434
result.grad = T.zeros_like(result.value)
3535
result.requires_grad = true
3636

src/nn/gates/leaky_relu.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Num::NN::LeakyReluGate(T) < Num::Grad::Gate(T)
3232
[Num::NN.leaky_relu_prime(gradient, @cache)]
3333
end
3434

35-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
35+
def cache(result : Num::Grad::Variable(T), *args)
3636
result.grad = T.zeros_like(result.value)
3737
result.requires_grad = true
3838

src/nn/gates/linear.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Num::NN::LinearGate(T) < Num::Grad::Gate(T)
5353
result
5454
end
5555

56-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
56+
def cache(result : Num::Grad::Variable(T), *args)
5757
input, weight, bias = args
5858
result.grad = T.zeros_like(result.value)
5959
Num::Grad.register("Linear", self, result, input, weight, bias)

src/nn/gates/relu.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Num::NN::ReluGate(T) < Num::Grad::Gate(T)
3232
[Num::NN.relu_prime(gradient, @cache)]
3333
end
3434

35-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
35+
def cache(result : Num::Grad::Variable(T), *args)
3636
result.grad = T.zeros_like(result.value)
3737
result.requires_grad = true
3838

src/nn/gates/sigmoid.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Num::NN::SigmoidGate(T) < Num::Grad::Gate(T)
3232
[Num::NN.sigmoid_prime(gradient, @cache)]
3333
end
3434

35-
def cache(result : Num::Grad::Variable(T), *args : Num::Grad::Variable(T))
35+
def cache(result : Num::Grad::Variable(T), *args)
3636
result.grad = T.zeros_like(result.value)
3737
result.requires_grad = true
3838

src/nn/initialization.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ module Num::NN
4444
end
4545

4646
product = 1
47-
2.step(to: shape.size - 1) do |i|
47+
1.step(to: shape.size - 1) do |i|
4848
product *= shape[i]
4949
end
5050

src/tensor/linalg.cr

+8-8
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ class Tensor(T)
171171
#
172172
# Examples
173173
# --------
174-
# ```crystal
174+
# ```
175175
# t = [[0, 1], [1, 1], [1, 1], [2, 1]].to_tensor.as_type(Float32)
176176
# q, r = t.qr
177177
# puts q
@@ -210,7 +210,7 @@ class Tensor(T)
210210
#
211211
# Examples
212212
# --------
213-
# ```crystal
213+
# ```
214214
# t = [[0, 1], [1, 1], [1, 1], [2, 1]].to_tensor.as_type(Float32)
215215
# a, b, c = t.svd
216216
# puts a
@@ -246,7 +246,7 @@ class Tensor(T)
246246
#
247247
# Examples
248248
# --------
249-
# ```crystal
249+
# ```
250250
# t = [[0, 1], [1, 1]].to_tensor.as_type(Float32)
251251
# w, v = t.eigh
252252
# puts w
@@ -281,7 +281,7 @@ class Tensor(T)
281281
#
282282
# Examples
283283
# --------
284-
# ```crystal
284+
# ```
285285
# t = [[0, 1], [1, 1]].to_tensor.as_type(Float32)
286286
# w, v = t.eig
287287
# puts w
@@ -369,7 +369,7 @@ class Tensor(T)
369369
#
370370
# Examples
371371
# --------
372-
# ```crystal
372+
# ```
373373
# t = [[0, 1], [1, 1], [1, 1], [2, 1]].to_tensor.as_type(Float32)
374374
# t.norm # => 3.6055512
375375
# ```
@@ -388,7 +388,7 @@ class Tensor(T)
388388
#
389389
# Examples
390390
# --------
391-
# ```crystal
391+
# ```
392392
# t = [[1, 2], [3, 4]].to_tensor.astype(Float32)
393393
# puts t.det # => -2.0
394394
# ```
@@ -419,7 +419,7 @@ class Tensor(T)
419419
#
420420
# Examples
421421
# --------
422-
# ```crystal
422+
# ```
423423
# t = [[1, 2], [3, 4]].to_tensor.as_type(Float32)
424424
# puts t.inv
425425
#
@@ -448,7 +448,7 @@ class Tensor(T)
448448
#
449449
# Examples
450450
# --------
451-
# ```crystal
451+
# ```
452452
# a = [[3, 1], [1, 2]].to_tensor.astype(Float32)
453453
# b = [9, 8].to_tensor.astype(Float32)
454454
# puts a.solve(b)

src/tensor/tensor.cr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,7 @@ class Tensor(T)
17761776
arg = arg.begin...@shape[i]
17771777
end
17781778
end
1779-
s, o = Indexable.range_to_index_and_count(arg, @shape[i])
1779+
s, o = Indexable.range_to_index_and_count(arg, @shape[i]).not_nil!
17801780
if s >= @shape[i]
17811781
raise Num::Internal::IndexError.new(
17821782
"Index #{arg} out of range for axis #{i} with size #{@shape[i]}"
@@ -1788,7 +1788,7 @@ class Tensor(T)
17881788
private def normalize(arg : Tuple(Range(B, E), Int), i : Int32) forall B, E
17891789
range, step = arg
17901790
abs_step = step.abs
1791-
start, offset = Indexable.range_to_index_and_count(range, @shape[i])
1791+
start, offset = Indexable.range_to_index_and_count(range, @shape[i]).not_nil!
17921792
if start >= @shape[i]
17931793
raise Num::Internal::IndexError.new(
17941794
"Index #{arg} out of range for axis #{i} with size #{@shape[i]}"

0 commit comments

Comments
 (0)