Skip to content

Commit a843c83

Browse files
jvdp1Vandenplas, Jeremie
andauthored
Remove some unused variables and a broadcast (#180)
* Remove unused variables * remove batch_end variable as unused --------- Co-authored-by: Vandenplas, Jeremie <[email protected]>
1 parent e82d565 commit a843c83

File tree

7 files changed

+7
-16
lines changed

7 files changed

+7
-16
lines changed

example/cnn_mnist.f90

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ program cnn_mnist
1111
real, allocatable :: training_images(:,:), training_labels(:)
1212
real, allocatable :: validation_images(:,:), validation_labels(:)
1313
real, allocatable :: testing_images(:,:), testing_labels(:)
14-
real, allocatable :: input_reshaped(:,:,:,:)
15-
real :: acc
16-
logical :: ok
1714
integer :: n
1815
integer, parameter :: num_epochs = 10
1916

example/get_set_network_params.f90

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ program get_set_network_params
99
integer, parameter :: test_size = 30
1010
real :: xtest(test_size), ytest(test_size)
1111
real :: ypred1(test_size), ypred2(test_size)
12-
integer :: i, n, nparam
13-
real, allocatable :: parameters(:)
12+
integer :: i, n
1413

1514
print '("Getting and setting network parameters")'
1615
print '(60("="))'

example/quadratic.f90

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ program quadratic_fit
2424
real, allocatable :: x(:), y(:) ! training data
2525
real, allocatable :: xtest(:), ytest(:) ! testing data
2626

27-
integer :: i, n
27+
integer :: i
2828

2929
print '("Fitting quadratic function")'
3030
print '(60("="))'
@@ -277,7 +277,7 @@ subroutine rmsprop_optimizer( &
277277
real, intent(in) :: xtest(:), ytest(:)
278278
real, intent(in) :: learning_rate, decay_rate
279279
integer, intent(in) :: num_epochs
280-
integer :: i, j, n
280+
integer :: i, n
281281
real, allocatable :: ypred(:)
282282

283283
print '(a)', 'RMSProp optimizer'
@@ -446,4 +446,4 @@ subroutine shuffle(arr)
446446
end do
447447
end subroutine shuffle
448448

449-
end program quadratic_fit
449+
end program quadratic_fit

src/nf/nf_network_submodule.f90

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,10 @@ module subroutine train(self, input_data, output_data, batch_size, &
596596
integer, intent(in) :: epochs
597597
class(optimizer_base_type), intent(in), optional :: optimizer
598598
class(loss_type), intent(in), optional :: loss
599-
class(optimizer_base_type), allocatable :: optimizer_
600599

601600
real :: pos
602601
integer :: dataset_size
603-
integer :: batch_start, batch_end
602+
integer :: batch_start
604603
integer :: i, j, n
605604
integer :: istart, iend, indices(2)
606605

@@ -630,11 +629,9 @@ module subroutine train(self, input_data, output_data, batch_size, &
630629
! Pull a random mini-batch from the dataset
631630
call random_number(pos)
632631
batch_start = int(pos * (dataset_size - batch_size + 1)) + 1
633-
batch_end = batch_start + batch_size - 1
634632

635633
! FIXME shuffle in a way that doesn't require co_broadcast
636634
call co_broadcast(batch_start, 1)
637-
call co_broadcast(batch_end, 1)
638635

639636
! Distribute the batch in nearly equal pieces to all images
640637
indices = tile_indices(batch_size)
@@ -658,7 +655,6 @@ module subroutine update(self, optimizer, batch_size)
658655
class(network), intent(in out) :: self
659656
class(optimizer_base_type), intent(in), optional :: optimizer
660657
integer, intent(in), optional :: batch_size
661-
class(optimizer_base_type), allocatable :: optimizer_
662658
integer :: batch_size_
663659
real, allocatable :: params(:)
664660
integer :: n

test/test_flatten_layer.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ program test_flatten_layer
99

1010
type(layer) :: test_layer, input_layer
1111
type(network) :: net
12-
real, allocatable :: input_data(:,:,:), gradient(:,:,:)
12+
real, allocatable :: gradient(:,:,:)
1313
real, allocatable :: output(:)
1414
logical :: ok = .true.
1515

test/test_get_set_network_params.f90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ program test_get_set_network_params
33
use nf, only: conv2d, dense, flatten, input, maxpool2d, network
44
implicit none
55
type(network) :: net
6-
integer :: n
76
logical :: ok = .true.
87
real :: test_params_dense(8) = [1, 2, 3, 4, 5, 6, 7, 8]
98
real :: test_params_conv2d(10) = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

test/test_optimizers.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ program test_optimizers
88
real, allocatable :: x(:), y(:)
99
real, allocatable :: ypred(:)
1010
integer, parameter :: num_iterations = 1000
11-
integer :: n, i
11+
integer :: n
1212
logical :: ok = .true.
1313
logical :: converged = .false.
1414

0 commit comments

Comments
 (0)